Table of Contents
Running multiple instances of the same Linux distribution on Windows Subsystem for Linux (WSL) is possible and can be quite useful for testing, development, or isolating different environments. Each instance runs independently, so you can configure, install software, and set up environments as needed. Each instance will have its own filesystem and configuration.
PS C:\> wsl -l -v
NAME STATE VERSION
* Ubuntu Stopped 2
PS C:\>
PS C:\> wsl --install -d ubuntu
Ubuntu is already installed.
Launching Ubuntu...
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
bonben@win11-e2208:~$
Install WSL and Your Desired Linux Distribution
Before you can create multiple instances, ensure that WSL is installed and you have your desired Linux distribution installed (e.g., Ubuntu).
Right-click on the Windows Start icon then open PowerShell (Terminal) as administrator.
Run the following command:
wsl --install
This command will install the default WSL distro, typically Ubuntu. This will be your base distribution.. If WSL is already installed, you can skip this step.
PS C:\> wsl --install
Installing: Virtual Machine Platform
Virtual Machine Platform has been installed.
Installing: Windows Subsystem for Linux
Windows Subsystem for Linux has been installed.
Installing: Ubuntu
Ubuntu has been installed.
The requested operation is successful.
Changes will not be effective until the system is rebooted.
Export the Base Distribution
Once your distribution is installed, you need to export it so that you can create multiple instances from this base.
PS C:\> wsl -l -v
NAME STATE VERSION
* Ubuntu Stopped 2
Open a PowerShell terminal and run the following command, replacing with the name of your installed distribution (e.g., Ubuntu):
wsl --export ubuntu 'D:\backup\mydistro.tar'
This command will export your current WSL distribution to a .tar file at the specified path.
Import the Distribution as a New Instance
Now that you have the exported .tar file, you can import it as a new instance. Run the following command to import the .tar file as a new WSL instance:
wsl --import <NewDistroName> 'C:\path\to\new\instance\' 'C:\path\to\backup\mydistro.tar'
- <NewDistroName>: The name you want to give the new instance (e.g., Ubuntu-Instance2).
- C:\path\to\new\instance\: The directory where the new instance’s filesystem will be stored.
- C:\path\to\backup\mydistro.tar: The path to the exported .tar file.
# Example
wsl --import Ubuntu-Instance2 'D:\wsl\Ubuntu-Instance2' 'D:\backup\mydistro.tar'
After importing, you will have multiple instances of the same Linux distribution. You can manage these instances with the following commands:
wsl -l -v
This will show you all the installed WSL distributions, including the new instance you just created.
PS C:\> wsl -l -v
NAME STATE VERSION
* Ubuntu Stopped 2
Ubuntu-Instance2 Stopped 2
To start a specific instance, replace <NewDistroName> with the name of the instance you want to run.
wsl -d <NewDistroName>
To terminate a running instance, run the below command. This will stop the specified WSL instance.
wsl --terminate <DistroName>
If you no longer need an instance, you can unregister it. This will delete the instance and its filesystem.
wsl --unregister <DistroName>
Not a reader? Watch this related video tutorial:
Related Titles:
- How to Clone a Linux Distro in WSL
- Managing Multiple Linux Instances on WSL
- Running Multiple Ubuntu Instances on Windows Subsystem for Linux
- How to Create Multiple WSL Instances for Developers
- WSL Tips: Run Multiple Versions of the Same Linux Distribution
- Step-by-Step Guide to Duplicating Linux Environments in WSL
- How to Setup Multiple WSL Instances on Windows 10/11
- Using WSL to Run Multiple Linux Distributions Simultaneously
- Advanced WSL Setup: Running Multiple Linux Instances
- How to Create Multiple Ubuntu Instances on Windows
- Running Multiple WSL Environments for Testing and Development
- How to Export and Import WSL Distros for Multiple Instances
- Managing Multiple Ubuntu Distributions on Windows WSL
- Create and Manage Multiple Linux Distro Instances on WSL
- Windows Subsystem for Linux: Running Multiple Instances
Keywords: WSL multiple instances, run multiple Linux on WSL, duplicate WSL distro, WSL import export guide, multiple Ubuntu WSL, WSL tips and tricks, Linux distribution WSL, managing WSL environments, WSL setup multiple instances, Windows Subsystem for Linux tutorial, running Linux on Windows, multiple Linux distributions WSL, WSL how to, duplicate Ubuntu on WSL, tech guide WSL
Hashtags: #WSL #LinuxOnWindows #WSLTutorial #TechGuide #MultipleInstances #UbuntuWSL #Windows10 #Windows11 #DeveloperTools #LinuxDistro #Bonguides