This page shows how to install Windows Subsystem for Linux (WSL) system on a non-system drive manually. It can work with both WSL 1 and WSL 2.
Enable Windows Subsystem for Linux system feature
Open PowerShell as Administrator and run the following command to enable WSL feature:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Create a folder in a non-system drive
Run the following command in PowerShell to create a folder for the installation. For my environment, I will create the folder in F drive.
cd F:\mkdir WSLcd WSL
Download a Linux distro
Run the following command in PowerShell to download a distro:
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile Ubuntu.appx -UseBasicParsing
The following distros are available:
- Ubuntu
- Ubuntu 20.04
- Ubuntu 20.04 ARM
- Ubuntu 18.04
- Ubuntu 18.04 ARM
- Ubuntu 16.04
- Debian GNU/Linux
- Kali Linux
- SUSE Linux Enterprise Server 12
- SUSE Linux Enterprise Server 15 SP2
- SUSE Linux Enterprise Server 15 SP3
- openSUSE Tumbleweed
- openSUSE Leap 15.3
- openSUSE Leap 15.2
- Oracle Linux 8.5
- Oracle Linux 7.9
- Fedora Remix for WSL
Unpack the downloaded distro
Run the following PowerShell commands to unpack:
move .\Ubuntu.appx .\Ubuntu.zipExpand-Archive .\Ubuntu.zip
Initialize Linux distro
In the unzipped folder, there is one executable (*.exe).
cd .\Ubuntu\ls
Directory: F:\WSL\Ubuntu
Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 15/05/2019 7:40 PM AppxMetadata d----- 15/05/2019 7:40 PM Assets -a---- 17/08/2018 3:15 AM 212438 AppxBlockMap.xml -a---- 17/08/2018 3:15 AM 3835 AppxManifest.xml -a---- 17/08/2018 3:17 AM 11112 AppxSignature.p7x -a---- 17/08/2018 3:15 AM 223983209 install.tar.gz -a---- 17/08/2018 3:15 AM 5400 resources.pri -a---- 17/08/2018 3:15 AM 211968 ubuntu1804.exe -a---- 17/08/2018 3:15 AM 744 [Content_Types].xml
* Based on the version of Linux distro you are using, the executable name can be different.
Run the executable to initialize:
.\ubuntu1804.exePS F:\WSL\Ubuntu> .\ubuntu1804.exe Installing, this may take a few minutes... Please create a default UNIX user account. The username does not need to match your Windows username. For more information visit: https://aka.ms/wslusers Enter new UNIX username: raymond Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Installation successful! To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details.
* You need to input a user name and password. I am using username raymond with**‘password’** as password.
Once the installation is done, you can see a new folder is created:
PS F:\WSL\Ubuntu> ls
Directory: F:\WSL\Ubuntu
Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 15/05/2019 7:40 PM AppxMetadata d----- 15/05/2019 7:40 PM Assets
da---- 15/05/2019 7:47 PM rootfs d----- 15/05/2019 7:49 PM temp -a---- 17/08/2018 3:15 AM 212438 AppxBlockMap.xml -a---- 17/08/2018 3:15 AM 3835 AppxManifest.xml -a---- 17/08/2018 3:17 AM 11112 AppxSignature.p7x -a---- 17/08/2018 3:15 AM 223983209 install.tar.gz -a---- 17/08/2018 3:15 AM 5400 resources.pri -a---- 17/08/2018 3:15 AM 211968 ubuntu1804.exe -a---- 17/08/2018 3:15 AM 744 [Content_Types].xml
If you install WSL from Microsoft Store, the default folder in your Windows user profile will be used:
%localappdata%\Packages
rootfs folder includes the following folders:
PS F:\WSL\Ubuntu> cd .\rootfs\ PS F:\WSL\Ubuntu\rootfs> ls
Directory: F:\WSL\Ubuntu\rootfs
Mode LastWriteTime Length Name ---- ------------- ------ ---- da---- 15/05/2019 7:47 PM bin da---- 15/05/2019 7:44 PM boot da---- 15/05/2019 7:44 PM dev da---- 15/05/2019 7:48 PM etc da---- 15/05/2019 7:48 PM home da---- 15/05/2019 7:44 PM lib da---- 15/05/2019 7:44 PM lib64 da---- 15/05/2019 7:44 PM media da---- 15/05/2019 7:47 PM mnt da---- 15/05/2019 7:44 PM opt da---- 15/05/2019 7:44 PM proc da---- 15/05/2019 7:44 PM root da---- 15/05/2019 7:44 PM run da---- 15/05/2019 7:44 PM sbin da---- 15/05/2019 7:44 PM snap da---- 15/05/2019 7:44 PM srv da---- 15/05/2019 7:44 PM sys da---- 15/05/2019 7:56 PM tmp da---- 15/05/2019 7:46 PM usr da---- 15/05/2019 7:47 PM var -a---- 15/05/2019 7:56 PM 87944 init
These folders include all the Ubuntu folders (libs, executables, etc.).
List all the WSL installations
You can install many Linux distributions in one Windows system.
wslconfig command can be used to list all the installed distributions and set default distribution:
wslconfig Performs administrative operations on Windows Subsystem for LinuxUsage: /l, /list [/all] - Lists registered distributions. /all - Optionally list all distributions, including distributions that are currently being installed or uninstalled. /s, /setdefault <DistributionName> - Sets the specified distribution as the default. /u, /unregister <DistributionName> - Unregisters a distribution.
Find out all the WSL installations in your Windows system using the following command:
wslconfig /l Windows Subsystem for Linux Distributions: Ubuntu-18.04 (Default)
Set default distribution:
wslconfig /setdefault Ubuntu-18.04
Run the following command to start the default WSL distribution:
wsl
To uninstall a distribution, use the following command:
wslconfig /u distribution_name
Now you have a WSL installed in a non-system drive. Have fun!