A guide for myself—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 of installing the Windows Subsystem for Linux version 2 (WSL2) on Windows 11 Pro and installing AlmaLinux 9 onto a non-default drive (D:), ensuring a secure and efficient setup.
- Open PowerShell as Administrator.
- Enable WSL by running:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all
- Enable the Virtual Machine Platform (required for WSL2):
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all
- Restart the computer when prompted.
- Open PowerShell as Administrator.
- Set WSL2 as the default version:
wsl --set-default-version 2
- Download the AlmaLinux 9 WSL package from AlmaLinux WSL.
- Locate and double-click the
.appx
file to launch the App Installer. - Click Install to proceed.
- Open PowerShell or Command Prompt.
- Verify the installation:
wsl -l -v
- Launch AlmaLinux 9:
wsl -d AlmaLinux9
- Create a user account and set a strong password.
- You can check AlmaLinux 9 instance running or stopped
wsl --list --verbose
By default, WSL distributions are installed on the C: drive. This section guides you through moving AlmaLinux 9 to the D: drive for better disk management.
- Open File Explorer.
- Navigate to:
C:\Users\<YourUsername>\AppData\Local\Packages
- Locate the folder named:
AlmaLinuxOSFoundation.AlmaLinux9_<some_unique_string>
- Open the folder, then navigate to LocalState.
- Find
ext4.vhdx
, which contains your AlmaLinux 9 installation.
- Open PowerShell as Administrator.
- Make sure you have Shutdown AlmaLinux 9.
- 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:
Or shut down all WSL instances:
wsl -t AlmaLinux9
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 user AlmaLinux 9:
wsl -d AlmaLinux9 -u almalinux
- Launch AlmaLinux 9:
wsl -d AlmaLinux9
- Confirm it is functioning correctly.
- Enable the firewall inside AlmaLinux:
wsl -d AlmaLinux9 sudo systemctl start firewalld sudo systemctl enable firewalld sudo firewall-cmd --set-default-zone=public
- Configure Windows Firewall rules if exposing network services.
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 dnf update -y
Stay vigilant with security best practices!
Harisfazillah Jamel LinuxMalaysia
20250401