WSL 2 Installation on Different Drive without import/export or link-shortcut.

Saransh Sinha
4 min readDec 9, 2023

--

WSL default installation is on Program Data and App Data.
When you have low space in your main OS drive, it is harder to manage WSL along with windows. There are many ways to set up WSL on your system for development or other needs.

In this article, I’m going to explain the BEST way to set up WSL 2 distro
We will not move or export/import anything, we will simply extract and run distro.exe file provided by Microsoft.Appx that will simply install everything to one palace.

I will recommend you to install, use this latest terminal from Microsoft
also If you have set up WSL 2 already, follow from the Step 4.

Step 1: Start PowerShell as administrator

Step 2: Run the following command to enable Windows subsystem for Linux or WSL on your system

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Restart

Step 3: After rebooting, open PowerShell with admin and run the following command to make sure everything is right

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Check the version of WSL, make sure it's WSL 2.0 or higher
Run the following command to check, if WSL is set up and is in fact WSL version 2, if version is not 2.0 or higher than follow the optional Step.

wsl --version 

Optional: switch WSL 1 to WSL 2

wsl --install
wsl --set-default-version 2

Step 4: Go to https://learn.microsoft.com/en-us/windows/wsl/install-manual#downloading-distributions and download distro of your choosing

I am going to choose Ubuntu 22.04 for explanation

Step 5: Changing the extension from .AppxBundle or .Appx to .zip and extract it.

You might see something like this. Or if not, please skip to step 7

Step 6: Look for the x64.appx, rename it to .zip and extract it.

Note: if you are using an ARM based CPU, you need to choose ARM64.appx

Now you are almost done

Step 7: copy the extracted folder to your any drive where you like to have WSL Linux and run .exe

you should see the default setup, set your username and password.

Well, that is how you can set up any Linux you want to custom location.

The only cons of using this method is that there is no start launcher, or sometimes you don't see disto on ms terminal, so there are some optional steps you may follow.

Optional step: Open terminal and go to settings

Step 1: add a new profile > new empty profile
Step 2: change name as you want
Step 3: change the command line to

C:\WINDOWS\system32\wsl.exe -d Ubuntu

Change the Ubuntu to what ever you have, run wsl — version

If you do not see any distro i sugguest you to put the direct Ubuntu.exe file path in command line.

Step 4: Change starting directory to

~

Step 5: Change Icon if you want to, you can find icons folder (.\Assets) in your distro folder.

Step 6: Save the changes and that's all.

After installation, there will be an ext4.vhdx file which is the main virtual disk.

If you ever wish to reset Linux simply run

wsl --list --verbose #to check all the installed distro
wsl --unregister Ubuntu #to remove the distro

The ext4.vhdx file will be deleted, and you can again run Ubuntu.exe setup file to start over.

Follow me on Medium and LinkedIn
Thank you

--

--

No responses yet