1 min read

Installing WSL to a Custom Location

Here, I delve into the process of installing the Windows Subsystem for Linux (WSL) on a custom location on your Windows 10 machine, making it easier for developers to manage and access their Linux environment.
Installing WSL to a Custom Location
Photo by Lukas / Unsplash

WSL is simply amazing! Providing you the power of Linux all within a Windows environment. Allowing us to switch seamlessly between OS using VSCode (since Linux development is so much easier).

But if you are like me and you are running WSL, you don't always want to install it to the C:\ drive (which is what you get when installing it from the Windows Store) but you want to be able to pick your own Drive. So how can we do this?

Finding our Distro

First find the link to the distro you want from this page: https://learn.microsoft.com/en-us/windows/wsl/install-manual#downloading-distributions

E.g., for Ubuntu 22.04 you can use: https://aka.ms/wslubuntu2204

Downloading and Installing WSL to your Drive

Next, read through the following using the link above for your distro:

# Navigate to the destination directory
cd E:\WSLTest

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

# Downloading Ubuntu 22.04
Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile Ubuntu.appx -UseBasicParsing

# Open the .AppxBundle in 7Zip and Extract the x86.appx file

# Unpack
move .\Ubuntu.appx .\Ubuntu.zip
Expand-Archive .\Ubuntu.zip

# Install
.\Ubuntu\ubuntu.exe

# Verify
wsl --list --all

Summary

When you now use wsl -l you will see your own installed