Cloud Explainers

WSL vs a Linux Virtual Machine: Which One Should You Use?

Linux9 min video

WSL or a Linux virtual machine? On one real Windows PC we ran Ubuntu both ways, WSL and a Hyper-V VM, and measured what matters: both started in about seven seconds (6.9 s vs 7.3 s), files on the C drive were about 40 times slower from WSL, other devices couldn't reach WSL until a port proxy, and after Windows restarted only the VM was still serving pages.

The speed guess

You want Linux on your Windows PC. You can use WSL, the Linux built into Windows, or a Linux virtual machine. Which one? Most people would bet on WSL for speed, so we timed both on the same PC. WSL: 6.9 seconds. The virtual machine took 7.3, counting until its web page answered. Less than half a second apart. That settles the speed argument, in about a second. Take Mike, who runs a small flower shop: his order page has to reach the counter tablet, and stay up through a restart. That's the real difference.

Same PC, cold start, timed: diagram of Windows, WSL, shop-server VM, One Windows PC

Two kinds of Linux on one PC

Here's what is really on a Windows PC running both. Guess first: is WSL a virtual machine too? Yes. Both are virtual machines: a computer made of software, running on Hyper-V, the part of Windows that runs virtual machines. WSL is one that Windows builds and runs for you. It starts the moment you type wsl, and stops when nobody uses it. The virtual machine is one you build yourself: its own disk, its own memory, its own network card. Think of WSL as a workbench in the back room of a shop, and the virtual machine as a second shop down the street, with its own address and opening hours.

One Windows PC, two ways to run Ubuntu: diagram of Windows, WSL, shop-server VM, Hyper-V, One Windows PC: 192.168.1.53

Here's Mike's shop. This weekend is Mother's Day, and the order page has to be open on Trish's tablet at the counter by eight on Saturday, or the orders go on paper. He builds it on his Windows PC. So which of the two should run it?

Mike's Flowers, Mother's Day weekend: diagram of Mike's Windows PC, Trish's tablet, Saturday's orders

You can see the difference with a few commands. wsl dash L dash V lists the Linux systems WSL has: here, Ubuntu, running, on WSL version two. uname dash R prints the kernel, the core of Linux that talks to the hardware. In WSL it ends in microsoft standard WSL two: Microsoft builds it, and every Linux you install in WSL shares it. Mike reaches the virtual machine with ssh, a remote terminal over the network. There it's Ubuntu's own kernel, the same one a real Ubuntu server would run.

Mike's PC: Windows PowerShell
PS C:\Users\mike> wsl -l -v  NAME            STATE           VERSION
* Ubuntu-24.04    Running         2
Mike's PC: Windows PowerShell
PS C:\Users\mike> wsl uname -r6.18.58.1-microsoft-standard-WSL2
Mike's PC: Windows PowerShell
PS C:\Users\mike> ssh mike@192.168.1.202 uname -r6.8.0-151-generic

Your programs run the same either way. What it changes for Mike is who updates the kernel. In WSL, Microsoft does. In the virtual machine, Ubuntu does, through apt, its package updater. And he can save the virtual machine as a checkpoint, a snapshot of the whole machine, before a risky change, and roll it back.

Updates and rollbacks: cards of Your programs, WSL's kernel, The VM's kernel, Checkpoints

Files on the C drive

Mike's order system writes one small file per order. Inside WSL, in his Linux home folder, writing two thousand files takes 0.1 seconds. WSL can also open the Windows C drive, in a folder called slash mnt slash C. Same loop, there. Guess first: how much slower? About 40 times slower: 4.3 seconds.

Mike's PC: Ubuntu in WSL
mkdir ~/orders && cd ~/orders && time (for i in $(seq 1 2000); do echo "roses" > order$i.txt; done)real	0m0.097s
user	0m0.016s
sys	0m0.080s
Mike's PC: Ubuntu in WSL
mkdir /mnt/c/Users/mike/orders && cd /mnt/c/Users/mike/orders && time (for i in $(seq 1 2000); do echo "roses" > order$i.txt; done)real	0m4.347s
user	0m0.036s
sys	0m0.216s

Why? WSL's home folder lives on its own Linux disk, inside its virtual machine. The C drive belongs to Windows, so every file opened there crosses the wall between the two, one request at a time. Microsoft's own advice says it plainly: for the fastest performance, keep your files in the WSL file system when you work from Linux.

Why the C drive is slow from WSL: diagram of WSL, WSL's own disk, C: drive, WSL's virtual machine

The virtual machine has the opposite problem. It can't see the C drive at all: there's no such folder. To share files with Windows, Mike would have to set up a network share. WSL's home folder, by contrast, even opens in Windows Explorer. So WSL wins easily for working on your own files, as long as they live on the Linux side.

shop-server: the Ubuntu VM
ls /mnt/cls: cannot access '/mnt/c': No such file or directory

Memory

Mike's PC has eight gigabytes, and the shop's till software needs its share. So which one eats more? WSL may grow to half the PC, 3.8 gigabytes here, but it takes memory only as it needs it: right now it is using about 440 megabytes. The virtual machine holds all of its two gigabytes the whole time it runs, busy or not. So on Mike's PC, the virtual machine costs more memory, all day. And if WSL ever takes too much, you can cap it with one line in a settings file called dot WSL config.

Memory on Mike's 8 GB PC: comparison table of WSL vs shop-server VM, Mike's PC, Ubuntu sees, Used right now, When idle, Holds memory when idle, To cap it

Can the tablet reach it?

Now the part that decides it for Mike. He starts the order page in WSL with Python's small test web server, on port eight thousand, a numbered door for web traffic. On his own PC it opens fine: status two hundred, which means OK. Then Trish tries it from the counter tablet, using the PC's address on the shop network. She uses curl, which fetches a page. Nothing. After 9 seconds, it gives up.

Mike's PC: Windows PowerShell
cd ~/shop && python3 -m http.server 8000 &[1] 458
Mike's PC: Windows PowerShell
PS C:\Users\mike> curl.exe -s -o NUL -w "%{http_code}" http://localhost:8000200
Mike's PC: Windows PowerShell
curl -m 10 http://192.168.1.53:8000curl: (7) Failed to connect to 192.168.1.53 port 8000 after 9088 ms: Couldn't connect to server

Here's why. WSL sits on its own private network inside the PC, on an address only the PC can reach. Windows only passes on traffic the PC sends to itself, to local host, the PC's name for itself. That's why it worked on Mike's own PC. On the screen that's one two seven dot zero dot zero dot one. Trish's request arrives at the PC's shop address, and nothing there is listening.

Why the tablet gets no answer: diagram of Trish's tablet, PC: 192.168.1.53, 127.0.0.1:8000, WSL, Mike's PC

First, Windows shows who listens on port eight thousand: only one two seven dot zero dot zero dot one. So Mike adds a port proxy: Windows listens on port eight thousand on every address and passes each connection on to WSL. Microsoft's own docs give this same fix. Windows also blocks new incoming connections by default, so a firewall rule lets that port in. Now Trish's tablet gets the order page.

Mike's PC: Windows PowerShell
PS C:\Users\mike> Get-NetTCPConnection -LocalPort 8000 -State Listen | ft LocalAddress,LocalPortLocalAddress LocalPort
------------ ---------
127.0.0.1         8000
Mike's PC: Windows PowerShell
PS C:\Users\mike> netsh interface portproxy add v4tov4 listenport=8000 listenaddress=0.0.0.0 connectport=8000 connectaddress=172.19.26.255
Mike's PC: Windows PowerShell
PS C:\Users\mike> New-NetFirewallRule -DisplayName 'Shop page 8000' -Direction Inbound -Protocol TCP -LocalPort 8000 -Action Allow | ft DisplayName,Enabled,ActionDisplayName    Enabled Action
-----------    ------- ------
Shop page 8000    True  Allow
Mike's PC: Windows PowerShell
curl -s http://192.168.1.53:8000 | grep -o '<title>.*</title>'<title>Mike's Flowers: Mother's Day orders</title>

Newer versions of Windows 11 have an easier way. It's called mirrored networking, one line in that same dot WSL config file. WSL then shares the PC's own network addresses, so no proxy. Mike's PC runs an older Windows, so the proxy is his option. And with either one, WSL still has to be running to answer.

Two ways to let the network reach WSL: cards of Mirrored mode, One line, Port proxy, Mike's PC

The virtual machine needs none of that. Hyper-V plugs its network card straight into the shop network, not behind Windows, so the shop's router gave it an address of its own: 192.168.1.202. The order page runs there as a service, a program the system keeps running. Trish types that address, and the page loads. No proxy, no extra rules.

shop-server: the Ubuntu VM
ip -4 -br addr show eth0eth0             UP             192.168.1.202/24 metric 100 
shop-server: the Ubuntu VM
systemctl is-active shopactive
shop-server: the Ubuntu VM
curl -s http://192.168.1.202:8000 | grep -o '<title>.*</title>'<title>Mike's Flowers: Mother's Day orders</title>

After a restart

Friday night, Windows installs its updates and restarts. Nobody signs in. Guess first: on Saturday morning, which one is serving orders? Only the virtual machine. Trish's tablet gets the page from it. From WSL, through the PC's address, it waits ten seconds and gets nothing.

Trish: the counter tablet
PS C:\Users\mike> Restart-Computer
Trish: the counter tablet
curl -s http://192.168.1.202:8000 | grep -o '<title>.*</title>'<title>Mike's Flowers: Mother's Day orders</title>
Trish: the counter tablet
curl -m 10 http://192.168.1.53:8000curl: (28) Operation timed out after 10003 milliseconds with 0 bytes received

Windows tells us why. WSL's Ubuntu is stopped: it only starts when someone signed in to Windows uses it. Hyper-V started the virtual machine by itself, the moment Windows came up, because Mike had set it to start automatically. Inside it, the order page's service started at boot.

Mike's PC: Windows PowerShell
PS C:\Users\mike> wsl -l -v  NAME            STATE           VERSION
* Ubuntu-24.04    Stopped         2
Mike's PC: Windows PowerShell
PS C:\Users\mike> Get-VM shop-serverName          State Uptime
----          ----- ------
shop-server Running 00:06:14.4010000
Mike's PC: Windows PowerShell
uptime -pup 6 minutes

So Mike moves the order page to the virtual machine for the weekend. Saturday, eight o'clock, Trish opens the tablet, and Mike's Flowers is there, ready for the first order.

After a restart: browser screenshot from the video

Which one to pick

So which one should you use? Use WSL when Linux is a tool for you: the shell, Git, Python, right next to your Windows apps. Just keep your files on the Linux side. Use a virtual machine when Linux serves other people: it has its own address, it starts with the PC, and you can snapshot it and roll it back. Mike keeps both: WSL to write the page, the virtual machine to serve it.

WSL or a Linux VM?: comparison table of WSL vs Linux VM, Start-up, Best for, Your files, Reachable by others, After a restart, Snapshots, In one line

Recap

Both start in seconds, and both run on Hyper-V. WSL is the workbench: fast for your own files on the Linux side, but only while someone is signed in. The virtual machine is the second shop: its own address, and open even when nobody is.

WSL or a VM: the recap: diagram of Windows, WSL, shop-server VM, Hyper-V, One Windows PC: 192.168.1.53

If this saved you an evening of guessing, subscribing brings the next comparison, tested on a real PC.

Every number in this video came from one real Windows PC, and the lab files are linked in the description. Thanks for watching Cloud Explainers.

Sources

Demos: one Windows PC in our own lab running WSL and a Hyper-V virtual machine, and a second machine standing in for the shop's tablet; the shop and its people are made up. Every command and line of output was real. Watch the full video on YouTube.

More videos

AWS8 min

Amazon Bedrock vs OpenRouter: Which One Should You Use?

Go (Golang)5 min

Golang Channels (chan) in 5 Minutes

Homelab & self-hosting21 min

Tailscale: Full Tutorial for Beginners

LLM infrastructure9 min

How RAG Works

Git11 min

Every Git Setting to Change on Day One

PostgreSQL9 min

Every PostgreSQL Setting to Change After You Install It

Docker9 min

What Happens When You Install Docker on Ubuntu

Python8 min

How to Fix Python 'Address Already in Use' Errors

Go (Golang)5 min

Golang Interfaces and Mocks in 5 Minutes

Git7 min

How to Fix Git 'Detached HEAD' State

Linux21 min

Linux Firewall with ufw: Full Tutorial for Beginners

Go (Golang)5 min

Golang defer Statements in 5 Minutes

Auth (OAuth, JWT)9 min

How to Fix OAuth 'invalid_grant' Errors

Databases & SQL11 min

The SQL Roadmap for Beginners

Go (Golang)5 min

Golang make() for Slices and Maps in 5 Minutes

Networking7 min

How to Fix Network 'No Route to Host' Errors on Linux

Linux6 min

How to Fix Linux 'Too Many Open Files' Errors

Django (Python web framework)11 min

Every Django Concept a Beginner Needs to Know

Linux24 min

SSH on Linux: Full Tutorial for Beginners

Go (Golang)5 min

Golang for range Loops in 5 Minutes

Databases & SQL10 min

SQL Databases: SQLite vs PostgreSQL

Django (Python web framework)10 min

The Django Roadmap for Beginners

Go (Golang)5 min

Golang Structs in 5 Minutes

Caching & Redis22 min

Redis: Full Tutorial for Beginners

Go (Golang)5 min

Golang context.Context in 5 Minutes

Databases & SQL7 min

How to Fix MySQL Database Error 1045: Access Denied for User

Go (Golang)5 min

Golang Method Receivers in 5 Minutes

Python8 min

How to Fix Python SSL: CERTIFICATE_VERIFY_FAILED Errors

Django (Python web framework)9 min

How to Fix Django Static Files Not Loading in Production

OpenRouter (one API for many AI models)8 min

OpenRouter vs Direct API Keys: Which One Should You Use?

Go (Golang)5 min

Golang if err != nil Checks in 5 Minutes

Go (Golang)8 min

How to Fix Golang 'go.mod File Not Found' Errors

AI agents & MCP22 min

MCP Servers: Full Tutorial for Beginners

Go (Golang)5 min

Golang Error Return Values in 5 Minutes

Python8 min

How to Fix Python ModuleNotFoundError: No Module Named

Go (Golang)5 min

Golang Pointers in 5 Minutes

Kubernetes8 min

How to Fix a Kubernetes Pod Stuck in CrashLoopBackOff

Homelab & self-hosting9 min

How to Fix a Homelab ESXi Host Not Responding

PostgreSQL24 min

PostgreSQL: Full Tutorial for Beginners

Load balancing & Nginx9 min

How a Load Balancer Works with HAProxy

Python9 min

How Python Virtual Environments Work

Homelab & self-hosting9 min

How to Fix Cloudflare Tunnel Errors in a Homelab

APIs9 min

How to Fix API CORS Errors: No 'Access-Control-Allow-Origin'

Auth (OAuth, JWT)9 min

How Authenticator App Login Codes Work (TOTP)

Git22 min

Git and GitHub: Full Tutorial for Beginners

Homelab & self-hosting10 min

How a Homelab Hypervisor Works (VMware ESXi)

Kubernetes9 min

How to Fix Kubernetes ImagePullBackOff Errors

DNS8 min

How to Fix DNS 'Temporary Failure in Name Resolution' on Linux

AWS8 min

How to Fix AWS CLI 'Unable to Locate Credentials'

Homelab & self-hosting10 min

Proxmox vs ESXi for Your Homelab: When Each One Wins

PostgreSQL10 min

PostgreSQL UUID vs Auto Increment: Which Primary Key Should You Use?

Kubernetes21 min

Kubernetes: Full Tutorial for Beginners

Networking9 min

How TCP Sockets Work

PostgreSQL7 min

How to Fix PostgreSQL 'Could Not Connect to Server'

Claude & the Claude Developer Platform9 min

Claude Code Hooks Will Finally Make Sense After This

DevOps & CI/CD9 min

DevOps with Ansible Will Finally Make Sense After This

Networking9 min

How SNMP Network Monitoring Works

Git8 min

How to Fix GitHub 'Permission Denied (publickey)' Errors

Docker21 min

Docker: Full Tutorial for Beginners

PostgreSQL7 min

How to Fix PostgreSQL 'Password Authentication Failed'

Linux8 min

Why One Linux Server Handles More Users Than You Think

Networking7 min

How to Fix Network 'Connection Refused' Errors

DevOps & CI/CD9 min

DevOps Pipelines: Jenkins vs GitHub Actions

Linux11 min

Linux Nginx Reverse Proxy: Full Tutorial for Beginners

Networking11 min

Every Networking Term a Beginner Needs in 12 Minutes

Docker6 min

How to Fix Docker 'Permission Denied' on docker.sock

Git7 min

How to Fix Git 'Updates Were Rejected' When You Push

Linux7 min

How to Fix nginx 502 Bad Gateway Errors on Linux

Linux8 min

How to Fix Linux apt 'Could Not Get Lock' Errors (Ubuntu)

Networking9 min

How Email Works on the Internet (SMTP) in 10 Minutes

Python8 min

The Python Roadmap for Beginners

Go (Golang)21 min

Golang REST API with Gin: Full Tutorial for Beginners

Networking10 min

How a WireGuard VPN Network Works

Linux9 min

Linux Makefiles Will Finally Make Sense After This

Auth (OAuth, JWT)9 min

SAML vs OAuth vs OpenID Connect: What's the Difference?

Python7 min

How to Fix Python cron Jobs That Never Run

Linux22 min

Linux Bash Scripting: Full Tutorial for Beginners

Networking10 min

How PXE Network Boot Works

Active Directory9 min

How Active Directory Works

Linux10 min

How to Fix a Linux systemd Service That Won't Start

Linux9 min

Linux Logs: syslog vs journald

Auth (OAuth, JWT)9 min

JWT vs Session Cookies: Which One Should You Use?

Docker10 min

Docker vs Docker Compose: Which One Should You Use?

Docker9 min

How to Fix Docker Compose Containers That Can't Talk to Each Other

Django (Python web framework)22 min

Django Full Tutorial for Beginners

Linux9 min

How Linux systemd Works

Networking8 min

How to Fix 'Windows Cannot Access' Network Share Errors (SMB)

APIs10 min

REST vs gRPC: Which One Should You Use?

Certificates & PKI (ADCS)9 min

How to Fix SSL Certificate Chain Errors (Missing Intermediate)

Python9 min

Every Python Concept for Beginners in 10 Minutes

Databases & SQL9 min

Every SQL Join Type in 10 Minutes

OpenRouter (one API for many AI models)9 min

Why OpenRouter Free Models Hit Their Limit So Fast

Gemini API & Google AI Studio9 min

Why Your Gemini API Free Tier Runs Out So Fast

OpenRouter (one API for many AI models)10 min

OpenRouter Will Finally Make Sense After This

Caching & Redis10 min

How Redis Caching Works

Gemini API & Google AI Studio10 min

Gemini API vs Vertex AI: Which One Should You Use?

Gemini API & Google AI Studio8 min

How to Fix a Leaked Gemini API Key

Go (Golang)9 min

Why Golang Uses Goroutines Instead of Threads

Gemini API & Google AI Studio9 min

How to Fix Gemini API Error 429: Resource Exhausted

Claude & the Claude Developer Platform10 min

Claude Token Pricing Will Finally Make Sense After This

Python11 min

Why Python Web Scraping Returns Nothing (and the Fix)

Python22 min

Python Automation: Full Tutorial for Beginners

Auth (OAuth, JWT)9 min

How OAuth Login Works

Python10 min

Python uv vs pip: Which One Should You Use?

Gemini API & Google AI Studio10 min

Google AI Studio Will Finally Make Sense After This

Docker10 min

What Happens When You Run a Docker Container

Claude & the Claude Developer Platform8 min

How to Fix Claude Code Billing Your API Key Instead of Your Plan

Auth (OAuth, JWT)9 min

Why Passkeys Can't Be Phished Like Passwords

PowerShell10 min

PowerShell vs Bash: Which One Should You Learn?

Linux10 min

The Linux Roadmap for Beginners

Django (Python web framework)9 min

Django vs FastAPI: Which One Should You Use?

Databases & SQL10 min

Why SQLite Is the Most Used Database in the World

Databases & SQL11 min

How a NoSQL Database Like MongoDB Works

Python11 min

How to Fix Python pip error: externally-managed-environment

Databases & SQL9 min

How to Fix MySQL Too Many Connections Database Errors

Go (Golang)9 min

Golang Concurrency Will Finally Make Sense After This

AWS10 min

How Amazon S3 Works

Kubernetes10 min

How Kubernetes Works

Git10 min

How Git Works

Docker10 min

How to Fix Docker Port Already Allocated Errors

PostgreSQL10 min

How PostgreSQL Works

Git8 min

How to Fix Git Merge Conflicts

Linux9 min

How to Fix No Space Left on Device in Linux

Networking10 min

How the Internet Works

Databases & SQL9 min

SQL vs NoSQL: When Each One Wins

Auth (OAuth, JWT)8 min

How to Fix JWT Token Expired Errors (401 Unauthorized)

Claude & the Claude Developer Platform9 min

Claude API vs Claude Pro: Why Your Subscription Doesn't Include It

AI agent skills9 min

Why AI Agent Skills Beat Giant Prompts

Linux10 min

Linux Cron Jobs Will Finally Make Sense After This

Cybersecurity10 min

Security Logs Will Finally Make Sense After This

Cybersecurity8 min

How to Fix a Security Leak: An API Key Pushed to GitHub

DNS9 min

DNS Will Finally Make Sense After This

Cybersecurity9 min

Never Ignore a Security Update

Auth (OAuth, JWT)9 min

Two-Factor Authentication Will Finally Make Sense

Networking8 min

Never Expose a Database to the Internet

Cybersecurity10 min

SSH Keys vs Passwords: Which Is Safer for Security?

Linux10 min

The 5 Levels of Linux Boot: From Power On to Login

Networking12 min

The 5 Levels of Network Firewalls

Cybersecurity10 min

Password Security: Why Hackers Crack Weak Passwords

Linux9 min

Why Your Linux Server Runs Out of Memory

Networking10 min

HTTP vs HTTPS: What Actually Changes on Your Network

Linux12 min

Every Linux File Permission You Need to Know

Linux10 min

Linux Processes vs Threads: When Each One Wins

Networking11 min

The OSI Model Will Finally Make Sense After This

Git11 min

The 7 Levels of Git

Networking10 min

Every Network Troubleshooting Command You Need

Cybersecurity10 min

Hashing vs Encryption in Cybersecurity: When Each One Wins

Networking11 min

Why the Internet Ran Out of IP Addresses

Linux11 min

Linux Package Managers: apt vs Snap vs Flatpak

Python9 min

Why Python Is Slow (and When It Doesn't Matter)

Networking11 min

TCP vs UDP: When Each One Wins

Linux8 min

Stop Running Linux as Root (Do This Instead)

Linux11 min

Linux Users and Groups Will Finally Make Sense

Cybersecurity9 min

Why Phishing Beats Good Security (and How to Spot It)

Docker12 min

The 7 Levels of Docker

AI agents & MCP12 min

AI Agents Will Finally Make Sense After This

Git8 min

Stop Using git push --force (Use This Instead)

AI agent skills10 min

Agent Skills vs MCP: When Each One Wins

Networking12 min

Networking Will Finally Make Sense After This

Linux12 min

Every Linux Command You Actually Need

Cybersecurity12 min

The 7 Levels of Cybersecurity

System design12 min

Every System Design Concept You Need, in One Diagram

PostgreSQL10 min

Why PostgreSQL Ignores Your Index