DEV Community


Posted on

Installing MSFT Store WSL Distros to a custom location

If you are running out of space on your C drive and want to keep your DEV environment and tools in a separate location for some reason, follow this guide.

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).

Grab the .appx package file:

To download the .appx package of a distro directly, run the following in PowerShell:

Invoke-WebRequest -Uri -OutFile Ubuntu.appx -UseBasicParsing
Enter fullscreen mode Exit fullscreen mode

This will download Ubuntu 20.04 distro and save it under the name “Ubuntu.appx”

Available Distros:

Ubuntu 20.04 -
Ubuntu 20.04 ARM -
Ubuntu 18.04 -
Ubuntu 18.04 ARM -
Ubuntu 16.04 -
Debian GNU/Linux -
Kali Linux -
OpenSUSE Leap 42 -

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 .\
Expand-Archive .\
Enter fullscreen mode Exit fullscreen mode


In the unzipped folder there’s an EXE file (according to the name of the distribution)


Based on the version of Linux distro you are using, the executable name can be different.

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>
Enter fullscreen mode Exit fullscreen mode


wsl.exe --import Debian1 D:\Deb1 .\install.tar.gz
Enter fullscreen mode Exit fullscreen mode

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”)
Enter fullscreen mode Exit fullscreen mode

Useful Links:

Discussion (0)