How to Run Multiple WSL Instances of the Same Ubuntu Distro on Windows

Running multiple same version instances of Ubuntu

Efficiently Manage Multiple Ubuntu WSL Instances on Windows

WSL
Linux environment
Windows Subsystem for Linux
tutorial
ubuntu

Check the required commands

If you run

wsl --help

Now if you scroll down, you will find this line:

wsl export command and detail

This helps us export and then import the same distribution. By doing this, you are effectively duplicating the same distribution, allowing you to run multiple instances of the same Linux environment.

Export Command

The export command is:

wsl --export <Distro> <FileName> [Options]
  • <Distro>: The name of the Ubuntu distribution that we want to copy (required).
  • <FileName>: The location and name that you want to save the new distro with your custom name (required).
  • [Options]: Optional parameters you can add.

To find the <Distro> name, run:

wsl -l -v

wsl list

This lists the installed WSL distributions.

Exporting the Ubuntu Distro

Run the export command based on your requirements:

wsl --export Ubuntu-22.04 E:\wslDistro\Ubuntu-22.04_export.tar

wsl exporting the ubuntu instance

Importing the Ubuntu Distro

The import command format is:

wsl --import <Distro> <InstallLocation> <FileName> [Options]
  • <Distro>: Name of the Distro we want to provide, you can add a suffix like _imported (required).
  • <InstallLocation>: The location where we want to store the distro-related file (required).
  • <FileName>: The location and name that we exported earlier using the wsl --export command (required).
  • [Options]: Optional parameters you can add.

Run the import command:

wsl --import Ubuntu-22.04_import E:\wslDistro\ E:\wslDistro\Ubuntu-22.04_export.tar

wsl importing the ubuntu instance

Run the New Distro

To list the WSL distributions:

wsl --list

wsl list command

You will see an extra distro that we just copied. To run the new distro:

wsl -d Ubuntu-22.04_import

wsl mount ubuntu instance

To navigate to the root folder and then to your home folder:

cd ~

wsl navigate to root

Now you can list files and folders:

ls

wsl list files and folder

You can also view the instance and its data inside the Windows Explorer:

wsl on windows explorer