WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Allow multiple instances of the utility VM to run simultaneously (WSL2)

Open conioh opened this issue 7 months ago • 3 comments

Is your feature request related to a problem? Please describe.

  1. Sometimes I want to run a WSL workload that requires a custom kernel. I want that the rest of my workloads to run under the standard kernel distributed by Microsoft. I want both those thing to happen concurrently.

  2. I want to run a long-lasting workload (e.g. some server), or otherwise a workload that I very much prefer to run uninterrupted. At the same time I want to run a bunch of less robust and trustworthy workloads (e.g. development, interactive, interacting with the custom kernel from the item above, etc.) that might crash WSL. I want that the second kind of workloads crashing WSL won't interrupt the first kind of workloads.

Describe the solution you'd like

I'd like to be able to run simultaneously multiple instances of WSL2 - that is, multiple instance of the uVM - as the same Windows user. It might look like an --instance parameter to wsl.exe:

> wsl --instance foo -d kali-linux --exec whatever &
[... Job Id whatever]

> wsl --instance bar -d Debian --exec something_else &
[... Job Id whatever]

> wsl --instance foo --shutdown # terminates the foo uVM but the bar uVM keeps running

> wsl -d Ubuntu # interact with the default instance, which is unnamed or has some predefined name (e.g. "WSL2")

Describe alternatives you've considered

  1. Using standard Hyper-V VMs I lose all the fun WSL integrations. I could just use Linux VMs like we did before WSL existed. Who needs it anyway? Anyone who want to use everything WSL2 provides that regular VMs don't

  2. Create dedicated Windows users, one per uVM, and run multiple WSL2 instances in multiple Windows users This has several problems:

    1. It's messy. It requires setting up (and removing?) users all the time.
    2. There are security difficulties - the other users might not have access to the host resources I want the guest to use. So in addition to creating users I have to adjusts DACLs all the time.
    3. I may not be running as admin on the host, so I don't have permissions to create new users. WSL2 is nice in that the WSL service which runs with high privileges uses the HCS/HNS/... APIs, while the wsl.exe command asks it to create VMs for it, and doesn't have to run elevated. This ruins it.

Additional context

conioh avatar Jun 12 '25 00:06 conioh

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here

Once completed please upload the output files to this Github issue.

Click here for more info on logging If you choose to email these logs instead of attaching to the bug, please send them to [email protected] with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

github-actions[bot] avatar Jun 12 '25 00:06 github-actions[bot]

/feature

conioh avatar Jun 12 '25 00:06 conioh

Diagnostic information
Found '/feature', adding tag 'feature'

github-actions[bot] avatar Jun 12 '25 00:06 github-actions[bot]