Blog

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.

Language: XML
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.

Language: XML
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.

Language: XML
Invoke-WebRequest -Uri https://aka.ms/wslubuntu2204 -OutFile Ubuntu_2204.appx -UseBasicParsing
Language: XML
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

Language: XML
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

Language: XML
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.

Language: XML
wsl --list --all
wsl --setdefault Ubuntu-22.04
wsl --shutdown
wsl

Removing

Language: XML
wsl --unregister Ubuntu-22.04

Exporting and Importing

Language: XML
wsl --export <distro> <filename.tar>
wsl --import <distro> <install location> <filename>