Why You Should Use Multiple Instances of Same Linux Distro on WSL (Windows 10)
How to Simplify Your Development Environments in Windows 10 by using Multiple Instances of Same Linux Distribution on Windows Subsystem for Linux (WSL).
Running Linux on Windows 10 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 unstable Linux environment that will impacts 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, 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.
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 “Apps & features”
Step 1.4: Select Linux Distro Name — e.g., Ubuntu 20.04 LTS
Step 1.5: Click on “Advanced Options” link
Step 1.6: Click on “Reset” button to reset your Linux Distro (e.g., Ubuntu 20.04 LTS) to 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 20.04 LTS) then setup your Linux Distro by entering username and password.
Step 1.8: Run “sudo apt-get update” (for Ubuntu 20.04 LTS) to retrieves information about what packages can be installed, including what updates to currently installed packages packages are available, from Internet sources.
Step 1.9: Run “sudo apt-get upgrade” (for Ubuntu 20.04 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 the multiple instances of same Linux Distro.
Step 2.1: Open a new command prompt or a new Powershell.
Step 2.2: Run the command “wsl — list” command to view a list of Windows Subsystem for Linux Distributions installed on your computer. For example on my computer, it would be “Ubuntu-20.04”.
Please note that the command is <wsl><space><dash><dash><space><list>.
Step 2.3: Run the command “wsl — export <DistributionName> <FileName>” or “wsl — export Ubuntu-20.04 rootfs.tar.gz” to export your Linux distros to a TAR file. This will create a file entitled “rootfs.tar.gz” on your computer.
Please note that the command is <wsl><space><dash><dash><space><export><space><Ubuntu-20.04><space><rootfs.tar.gz>.
Step 2.4: Copy the newly created file named “roofts.tar.gz” to your desired directory. For example on my computer, I have copied the file to c:\linux\ubuntu-20.04.01 directory.
3. Install New Instance of Same Linux Distro on WSL
The third step is to download, install and configure WSLDL. WSLDL is an open-source Advanced WSL Distribution Launcher / Installer that can be used to configure and launch a same Linux Distro as a different Linux instances.
Step 3.1: Download “Launcher.exe” from How to Install | Wsldl official documentation (wsldl-pg.github.io) and save the file to your desired directory. For example on my computer, I have saved the file to c:\linux\ubuntu-20.04.02 directory.
Step 3.2: Rename the file “Launcher.exe” to your desired Linux Distro name. For example on my computer, I have renamed to file to “Ubuntu-20.04.02.exe” to denote that this is Ubuntu 20.04 and appended “.02” for instance 2.
Step 3.3: To install WSLDL, open a new command prompt or a new Powershell then run the renamed file. For example on my computer, I have executed the file, entitled “Ubuntu-20.04.02.exe” in c:\linux\ubuntu-20.04.02 directory. The installation process should create \rootfs sub-directory with files under that sub-directory. Delete copied “rootfs.tar.gz” after the installation is completed.
After successful installation…
Step 3.4: To configure WSLDL to default to your username when you run your Linux Distro on WSL, run the command “Ubuntu-20.04.02 config — default-user <username>. For example on my computer, it would be “Ubuntu-20.04.02 config — default-user sungkim”.
Step 3.5: To run a newly installed Linux Distro on WSL, just run the command “Ubuntu-20.04.02.exe” in c:\linux\ubuntu-20.04.02 directory from command prompt or Powershell.
Step 3.6: You can pin the new Linux Distro to taskbar by selecting and right-clicking on the file “Ubuntu-20.04.02.exe” then selecting “Pin to taskbar” from the context menu. To change icon, you can download the icon here (https://github.com/yuk7/wsldl/tree/main/res) and change the icon to appropriate Linux Distro.
To install an additional instances of a same Linux Distro on WSL, repeat the step 3.2 to step 3.6 with different name for “Launcher.exe” with different directory name.
4. Configure your new Linux Environment
The fourth and final step is to configure your new Linux environment so you can start being productive.
Step 4.1: Run “sudo apt-get update” then “sudo apt-get upgrade” to update your software.
Step 4.2: Install Midnight Commander by running “sudo apt-get install mc”.
Step 4.3: Install Java by running “sudo apt install openjdk-11-jre-headless”.
Step 4.4: Install Go by running “sudo apt install golang-go”.
Step 4.5: Install Rust by running “sudo apt install rustc”.
Step 4.6: Install Visual Studio Code by running “code .”.
Now, you can start developing in three Linux environments concurrently as shown below: