January 25, 2023

3 easy ways to get multiple instances of WSL!

What if you want something different, custom or just have more instances of the same distribution? Microsoft Store provides a variety of Linux distributions to choose from, but it might be not enough at times. Luckily it turns out it is trivial to get what you want!

1st Method – Downloading

First one is the easiest of them all – just fetch a release straight from vendor’s download page.

curl --location `
  --remote-name `

wsl --import `
  UbuntuKinetic `
  "C:\ProgramData\UbuntuKinetic" `
  "ubuntu-kinetic-wsl-amd64-wsl.rootfs.tar.gz" --version 2

2nd Method – Cloning

Second is not much more difficult, as first we install a distribution from a Windows Store. Next the only thing needed is to export already installed distribution and import it under a different name. Really, that’s it 😉

wsl --list

wsl --export YOUR-CURRENT-DISTRO my-distribution.tar

wsl --import YOUR-NEW-DISTRO "C:\ProgramData\YOUR-NEW-DISTRO" my-distribution.tar

3rd Method – Docker

Third is not that difficult either on the surface, but your mileage may vary as these images might not be compatible with WSL.

docker run --name imagecontainer -t centos echo hello

docker export imagecontainer > distribuition-image.tar

wsl --import YOUR-NEW-DISTRO "C:\ProgramData\YOUR-NEW-DISTRO" distribuition-image.tar

This process is more described here, but unfortunately it didn’t work on my environment 🙁

PS > wsl -d UbuntuDesktop -e uname -a
Catastrophic failure
Error code: Wsl/Service/CreateInstance/E_UNEXPECTED

After enabling WSL debug console in .wslconfig ([wsl2] debugConsole=true) we can see following error

WSL (1) ERROR: ConfigInitializeEntry:1576: Failed to create /bin/wslpath -> /init

Not giving up yet, to be continued…

Final Thoughts

Importing WSL Distributions gives you a lot of power, as you can not only create multiple environments, but also run distributions that are not available in the store. Importantly you will get Windows Terminal integration out-of-the box, and other WSL only features that you don’t get with a full Virtual Machine. Although some features might require some tinkering and additional configuration.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.