There are lots of cases that we need a different instance of Ubuntu with the different configuration on WSL, but by default, we could install one instance of each Linux Distribution on WSL via Microsoft store. To solve this issue we must follow one of these ways:
- Import raw version of exported WSL with a different name.
- Download Linux Distribution Package from Windows Store and try to Import it as a different instance of WSL. In this tutorial, I am following a second way to install a new instance of Linux on WSL.
Download Linux Distribution
Download prefer Distribution of Linux from Microsoft website.
- Ubuntu 18.04
- Ubuntu 18.04 ARM
- Ubuntu 16.04
- Debian GNU/Linux
- Kali Linux
- OpenSUSE Leap 42
- SUSE Linux Enterprise Server 12
- Fedora Remix for WSL
Extract Linux Distribution
Extension of the downloaded file is APPX but you can extract it with 7Zip. Try to extract it to a folder with the same name.
Install new Instance of Linux in WSL
In an extracted folder you will find file install.tar.gz. The only step left is to import this file as a new instance of Linux in WSL. A WSL command contain 4 parts to import new instance:
- –import This section show that you want to import new instance.
- Instance Name This is unique name, that let us access to instance in future.
- Installation Path This is a location, that linux persist file system information.
- install.tar.gz Path This is a path of install.tar.gz file.
wsl --import Ubuntu-18.04_New [Intallation Path] [The Exctracted Folder]\install.tar.gz
for example
wsl --import Ubuntu-18.04_New C:\WSL\Data\Ubuntu-18.04-New C:\Downloads\Ubuntu18.04\install.tar.gz
View list of available instance
If you run the following command, you can see Ubuntu-18.04_New added as an available WSL instance.
wsl --list
Run a imported instance and add Sudoer user
When for the first time, you run an instance you will see your login with root user.
wsl --distribution Ubuntu-18.04_New
But most of the time, you want to login with a specific user. To do this first login to your new instance and execute following commands to create a new user and add it to the Sudoer group.
useradd testUser
passwd testUser
usermod -aG sudo testUser
Run a imported instance with testUser
wsl --distribution Ubuntu-18.04_New --user testUser