WSL. Ubuntu 22.04. How to Install on Non System Drive on Windows 11

Installing the Windows Subsystem for Linux (WSL) on a non-system drive in Windows 10 and Windows 11 is quite painful. Here is a step by step guide.

WSL. Ubuntu 22.04. How to Install on Non System Drive on Windows 11

Why Should You Install WSL on a Non System Drive?

Installing the Windows Subsistem for Linux (WSL) on a non-system drive in Windows 10 and Windows 11 is quite painful as it does not exist as an option during the installation. However its a must as modern laptops. These usually have small system drive -- this is where your Windows installation lives -- usuall the so called C: drive, most of which is taken by the Windows OS and supporting files itself. And a larger drive, which you should store to save any custom data -- your data.

Enable the WSL Feature of Windows

First to start you must have an admin access to the system so that you can enable WSL. To do this open PowerShell as an admin user and issue the following command.

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

After the feature is enabled, it will ask you to restart. This is perfectly fine, just click "y" and Enter to restart. Alternatively shutdown any open windows and use the normal way to restart your Windows OS.

Create New Directory for WSL on a Non System Drive

Create a new directory on your D: drive. Then change current directory to -- enter inside -- the new directory.

mkdir D://WSL && cd D://WSL

Download the Ubuntu 22.04 Application

At the moment of this writing there is no official link listed on the MS WSL website. Hopefully by the time you read it an official link will be provided. Try the link bellow and if it does not work, try the second link below.

Invoke-WebRequest -Uri https://aka.ms/wslubuntu2204 -OutFile Ubuntu_2204.appx -UseBasicParsing
Invoke-WebRequest -Uri https://dl.delivery.mp.microsoft.com/filestreamingservice/files/24fbec63-3ebe-44ed-bbde-53985bb6642b -OutFile Ubuntu_2204.appx -UseBasicParsing

Alternatively on one of the MS WSL threads the following advice was found for downloading the installation

Invoke-WebRequest -Uri https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64-wsl.rootfs.tar.gz -OutFile Ubuntu_2204.tar.gz -UseBasicParsing

Extract the Ubuntu 22.04 Archive

Rename-Item .\Ubuntu.appx Ubuntu.zip
Expand-Archive .\Ubuntu.zip -Verbose

Installing the Ubuntu 22.04 WSL

Open the directry in File Explorer, and click on the EXE file -- ubuntu2204.exe. It will open a CLI like environemnt and will ask you to set a username and password.

Setting Ubuntu 22.04 as the Default WSL

You may have multiple OS installed on the WSL. To make the newly installed Ubuntu 22.04 as the default list the available images, then set the default with the name listed from the previous command.

wsl --list --all
wsl --setdefault Ubuntu-22.04
wsl --shutdown
wsl

Removing

wsl --unregister Ubuntu-22.04

Exporting and Importing

wsl --export <distro> <filename.tar>
wsl --import <distro> <install location> <filename> 
Previous
How to Run Temporary Podman Images with Immediate Clean Up
Next
Postgres. Fixing Duplicate Key Value Violates Unique Constraint Error

Keep Reading

Explore more articles and insights

Ork: SSH Server Automation in Go

Ork: SSH Server Automation in Go

Read Article
Deno Deploy Killed My Start Page

Deno Deploy Killed My Start Page

Read Article
Back to Golang: Why I Switched From Static to Dynamic Again

Back to Golang: Why I Switched From Static to Dynamic Again

Read Article
View All Blog Posts