This article will let you to manually install any WSL distribution (on MSFT store) of your choice to a different folder or drive location.
By default the Linux distributions installed from the Microsoft Store are available in the same place as other Windows store apps (%USERPROFILE%\AppData\Local\Packages\).
Enabling the WSL windows feature:
In an administrator PowerShell window, run:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
and reboot to complete the installation.
Grab the .appx package file:
To download the .appx package of a distro directly, run the following in PowerShell:
Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile Ubuntu.appx -UseBasicParsing
This will download Ubuntu 20.04 distro and save it under the name “Ubuntu.appx”
Available Distros:
Ubuntu 20.04 - https://aka.ms/wslubuntu2004
Ubuntu 20.04 ARM - https://aka.ms/wslubuntu2004arm
Ubuntu 18.04 - https://aka.ms/wsl-ubuntu-1804
Ubuntu 18.04 ARM - https://aka.ms/wsl-ubuntu-1804-arm
Ubuntu 16.04 - https://aka.ms/wsl-ubuntu-1604
Debian GNU/Linux - https://aka.ms/wsl-debian-gnulinux
Kali Linux - https://aka.ms/wsl-kali-linux-new
OpenSUSE Leap 42 - https://aka.ms/wsl-opensuse-42
SLES - https://aka.ms/wsl-sles-12
Unpack the distro:
Navigate to the directory and extract the package. Extract to a folder that has full access permission.
You can unzip the downloaded package using any archiver of your choice, or you can simply do it via PowerShell itself:
move .\Ubuntu.appx .\Ubuntu.zipExpand-Archive .\Ubuntu.zip
Initializing
In the unzipped folder there’s an EXE file (according to the name of the distribution)
Now, run the executable to start initializing…
This will extract the “rootfs” and Register the WSL.
NOTE: You can register with a different name using wsl — import and perform multiple installs :)
wsl.exe --import <DistributionName> <InstallLocation> <FileName>
Eg:
wsl.exe --import Debian1 D:\Deb1 .\install.tar.gz
Wait till the process completes and you’ll be prompted to create a new user account and rest of the process follows accordingly.
After the installation is complete, you’ll find the “rootfs” folder is created which has all the libraries, executables etc…
To verify installation use wsl --list --all
or wsl -l --all
to list names of installed or imported WSL distros.
Adding to PATH
You’ll have to use the distribution launcher application in target folder every time to run your distro. So, additionally you can add your distro path to PATH environment variable to invoke it from anywhere.
$userenv = [System.Environment]::GetEnvironmentVariable(“Path”, “User”) [System.Environment]::SetEnvironmentVariable(“PATH”, $userenv + “;D:\DebianWSL”, “User”)
Useful Links:
https://docs.microsoft.com/en-us/windows/wsl/user-support?redirectedfrom=MSDN