Creating Additional WSL2 Instances
Last updated
Was this helpful?
Last updated
Was this helpful?
Get a rootfs. e.g. Ubuntu rootfs:
wsl.conf settings -
Configure global options with .wslconfig -
The first thing we’ll need is a root filesystem. Luckily Ubuntu make their WSL root filesystem available for download, which is available . For this walk-through I’ve created a directory on my Windows C: drive called “wsl”, we’ll place the rootfs files in c:\wsl\wslrootfs
and the distros in c:\wsl\wsldistros\
Download the file above to the wslrootfs directory.
Run wsl.exe --import base-ubuntu C:\wsl\wsldistros\base-ubuntu\ C:\wsl\wslrootfs\ubuntu-20.04-server-cloudimg-amd64-wsl.rootfs.tar.gz
In this command base-ubuntu
Is just a name you want to assign so for example a specific project. c:\wsl\wsldistros\base-ubuntu\
is the directory on your machine you want to place the virtual disk file for the distribution and then we have the distro file we downloaded
At this point you have a clean install of ubuntu 20.04 to use. You can then easily access each distribution you have available with Windows Terminal which places them all on a tab drop-down for easy access.
Configure it however you please. Consider using something like if this is going to be a fairly common process for you.
At this point, I'm specifying my naming convention moving forward.
<date-modified>-<type>-<distro>
20200714-base-ubuntu
Once we’ve got the tooling we want installed, we can export the rootfs for later use.
Then we can create new instances based off this by importing the 20200714-base-ubuntu
file we just created
and when we start it up, all our tools are in place :)
Once you’re finished with it, it can just be removed with wsl.exe --unregister <Name>
. This will delete the virtual disk file, however, as of writing the created folder is left behind.
Credit to Rory: