Phase 2: Install WSL2 and Move AlmaLinux 9 to Another Drive
A guide for myself (Harisfazillah Jamel aka LinuxMalaysia), born from my professional experience as a Linux system administrator and enhanced with AI tools to ensure comprehensive coverage and clarity for technical audiences.
This guide details the process installing AlmaLinux 9 Windows 11 Pro Windows Subsystem for Linux version 2 (WSL2), onto a non-default drive (D:), ensuring a efficient setup.
We assume, WSL2 distributions are installed on the C: drive. You can refer this link for Phase 1: Installing AlmaLinux 9 WSL2 on Windows 11 Pro.
Open File Explorer.
Navigate to
C:\Users\<YourUsername>\AppData\Local\Packages
Locate the folder named (as example)
AlmaLinuxOSFoundation.AlmaLinux9_<some_unique_string>
Open the folder, then navigate to LocalState.
Find ext4.vhdx
, which contains your AlmaLinux 9 installation.
Shutdown AlmaLinux 9 Before Backup
Open PowerShell as Administrator.
Shutdown AlmaLinux 9.
wsl -t AlmaLinux9
Or shut down all WSL instances.
wsl --shutdown
Use this command to make sure AlmaLinux9 instance stopped.
wsl --list --verbose
Create a Backup Folder (Optional)
Open PowerShell as Administrator.
Create a backup directory.
New-Item -ItemType Directory -Path "D:\WSL\AlmaLinux9-Template"
Copy the ext4.vhdx
file to the backup folder.
Copy-Item "C:\Users\<YourUsername>\AppData\Local\Packages\AlmaLinuxOSFoundation.AlmaLinux9_<unique_string>\LocalState\ext4.vhdx" -Destination "D:\WSL\AlmaLinux9-Template\ext4.vhdx"
Create the new installation folder.
New-Item -ItemType Directory -Path "D:\WSL\AlmaLinux9"
Shutdown AlmaLinux 9.
wsl -t AlmaLinux9
Or shut down all WSL instances.
wsl --shutdown
Unregister the existing AlmaLinux distribution.
wsl - unregister AlmaLinux9
Import the distribution from the new location.
wsl - import AlmaLinux9 D:\WSL\AlmaLinux9 D:\WSL\AlmaLinux9-Template\ext4.vhdx
Set the default for running AlmaLinux 9 (depending on the user you have created).
wsl -d AlmaLinux9 -u almalinux
Launch AlmaLinux 9.
wsl -d AlmaLinux9
The performance of AlmaLinux in WSL2 depends on the speed of the D drive. SSDs provide better performance than HDDs.
Congratulations! You have successfully installed WSL2 and moved AlmaLinux 9 to the D: drive. Remember to keep your system updated.
sudo systemctl start firewalld
sudo systemctl enable firewalld
sudo firewall-cmd --set-default-zone=public
Stay vigilant with security best practices.
Harisfazillah Jamel aka LinuxMalaysia
20250401
Originally published at https://gist.github.com/linuxmalaysia/491098eea7160aa184e85c19d6b68acc