Run Multiple Instances of the Same Linux Distro on WSL
How to Simplify Your Development Environments in Windows 10/11 by using Multiple Instances of the Same Linux Distribution on Windows Subsystem for Linux (WSL).
UPDATED ON NOVEMBER 2022 WITH UP-TO-DATE INSTRUCTIONS.
Running Linux on Windows 10/11 via WSL is great, which allows you to fully utilize all the development and system tools available on Linux. Like everything in life, your enthusiasm for the new tools will catch up to you. Installing different tools and configuring your Linux environment to run these tools will result in an unstable Linux environment that will impact your day-to-day productivity.
You can alleviate the eventual degradation of your Linux environment by installing and running different Linux distros from Microsoft Store (for example, you can run Ubuntu, Ubuntu 18.04 LTS, Ubuntu 20.04 LTS, Ubuntu 22.04 LTS, Kali Linux, and Debian at the same time), but you will find that some tools work differently in different Linux distro/version.

The solution is to run multiple instances of the same Linux Distro/Version on WSL. This article will provide step-by-step instructions on running multiple instances of the same Linux Distribution/Version on WSL.
Step-by-Step Instructions (Windows 11)
1. Reset Linux Distro on WSL
The first step is to create a baseline of your Linux distro/version. This is needed so you can have a fresh start when your Linux environment becomes unstable.
Step 1.1: Open “Settings”
Step 1.2: Click on “Apps”
Step 1.3: Click on “Installed Apps”
Step 1.4: Select Linux Distro Name — e.g., Ubuntu 22.04.1 LTS
Step 1.5: Click on the “Advanced Options” link
Step 1.6: Click on the “Reset” button to reset your Linux Distro (e.g., Ubuntu 22.04.1 LTS) to the initial install state. Please note that everything will be deleted.
Step 1.7: When the reset is completed, start your Linux Distro (e.g., Ubuntu 22.04.1 LTS) then set up your Linux Distro by entering both username and password.
Step 1.8: Run “sudo apt-get update” (for Ubuntu 22.04.1 LTS) to retrieve information about what packages can be installed, including what updates to currently installed packages are available, from Internet sources.
Step 1.9: Run “sudo apt-get upgrade” (for Ubuntu 22.04.1 LTS) to install available upgrades of all packages currently installed on the system from Internet sources.
2. Export Linux Distro on WSL
The second step is to create an export image of your Linux Distro. This image will be used to create multiple instances of the same Linux Distro.
Step 2.1: Open a new command prompt or a new Powershell.
Step 2.2: Run the command
wsl --listto view a list of Windows Subsystems for Linux Distributions installed on your computer. For example on my computer, it would be “Ubuntu-20.04”.

Step 2.3: Run the command
wsl --export <DistributionName> <FileName>or
wsl --export Ubuntu-22.04.1 rootfs.tar.gzto export your Linux distros to a TAR file. This will create a file entitled “rootfs.tar.gz” on your computer. Keep this file safe since you will need this file to create a new instance of the WSL Linux Distro.

Step 2.4: Copy the newly created file named “rootfs.tar.gz” to your desired directory. For example on my computer, I have copied the file to c:\linux directory.
3. Install a New Instance of the Same Linux Distro on WSL
Step 3.1. Open a new command prompt or a new Powershell then run the following command to import exported instance as a new instance of Linux in WSL.
wsl --import DistroName InstallationPath ExportedFileLocationfor example,
wsl --import Ubuntu-22.04.1.02 c:\linux\ubuntu-22.04.1.02 c:\linux\rootfs.tar.gzI have named DistroName as Ubuntu-22.04.1.02 to specify this is Ubuntu 22.04.1 Instance 2.
For WSL2, the installation process should create “ext4.vhdx” file. Delete copied “rootfs.tar.gz” after the installation is completed.

Step 3.2. Run the newly imported Linux distro.
wsl -d DistroNamefor example
wsl -d Ubuntu-22.04.1.02This should start the new instance of Linux Distro in WSL.

Step 3.3. Configure new Linux distro by creating “/etc/wsl.conf” file.
sudo nano /etc/wsl.confthen enter the following to wsl.conf file then save the file. This is needed to replicate the default behavior of your default Linux distro instance on WSL where you are logged in as a specified user and mounted to its home directory.
[automount]
enabled=true
root=/
[user]
default=sungkim
[interop]
appendWindowsPath = false
[boot]
systemd=truePlease note that you will have to change your username (e.g., sungkim). For more information on wsl.conf, please refer to this website from Microsoft => https://learn.microsoft.com/en-us/windows/wsl/wsl-config.
Step 3.4. Restart Linux Distro
Exit out of Linux Distro
exitthen from either the command prompt or PowerShell, enter
wsl --shutdownClose Windows Terminal then restart Windows Terminal. A new WSL instance will just show up in Windows Terminal. In Windows Terminal, click on drop-arrow then select the Linux distro name (e.g., Ubuntu-22.04.1.02) to start your new terminal session.
Please note the following differences between a default WSL instance (e.g., Ubuntu 22.04.1) and the imported WSL instances (e.g., Ubuntu 22.04.1.02):
- To navigate to a host computer (Windows 10/11)’s file system, change the directory to “cd /c” instead of “cd /mnt/c” where the “c” is the drive name.
Conclusion
I hope this tutorial is helpful for you. One tip I would like to leave you with is that whenever you start a WSL session, it will run in the background. You may want to execute “wsl — shutdown” in Powershell to terminate all running WSL instances.






