Windows Subsystem for Linux (WSL) allows you to run Linux distributions natively on your Windows Server environment, enabling developers and IT professionals to use Linux tools and workflows seamlessly. While enabling WSL on Windows Server 2022 is slightly different from enabling it on Windows 10 or 11, the process is straightforward. This guide will walk you through the steps to enable WSL and install a Linux distribution on Windows Server 2022.
Prerequisites
Before proceeding, ensure that:
- You are running Windows Server 2022.
- You have administrator privileges.
- The server has an active internet connection.
Step 1: Install the Required Features
WSL requires specific Windows features to be enabled. To install these features, follow these steps:
Using PowerShell
- Open PowerShell as an administrator.
- Run the following command to enable the necessary features:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
- Restart your server to apply the changes:
Restart-Computer
Using Server Manager
- Open Server Manager.
- Navigate to Add roles and features.
- Click through the wizard until you reach the Features section.
- Check the boxes for:
- Windows Subsystem for Linux
- Virtual Machine Platform
- Complete the wizard and restart the server.
Step 2: Update the WSL Kernel
Microsoft provides an updated WSL kernel that needs to be installed manually on Windows Server. Here’s how:
- Download the WSL kernel update package from the Microsoft website.
- Run the installer and follow the prompts.
Step 3: Set WSL 2 as the Default Version (Optional)
WSL 2 offers better performance and full system call compatibility. To set WSL 2 as the default version, use the following command:
wsl --set-default-version 2
If you encounter an error indicating that your hardware does not support WSL 2, ensure that virtualization is enabled in your server’s BIOS/UEFI settings.
Step 4: Install a Linux Distribution
With WSL enabled, you can now install a Linux distribution:
- Open PowerShell as an administrator.
- List available distributions by running:
wsl --list --online
- Install your preferred distribution (e.g., Ubuntu):
wsl --install -d Ubuntu
- Wait for the installation to complete. Once finished, the Linux distribution will launch, and you will be prompted to create a user account.
Step 5: Verify the Installation
To confirm that WSL is installed and working:
- Open PowerShell.
- Run the following command:
wsl --list --verbose
This will display the installed distributions and their WSL version.
- Launch the Linux distribution by typing its name in PowerShell (e.g.,
ubuntu
).
Additional Configuration
Conclusion
Enabling WSL on Windows Server 2022 allows you to leverage the power of Linux tools directly within your server environment. Whether you are a developer or an IT professional, WSL provides a seamless way to integrate Windows and Linux workflows. By following the steps in this guide, you’ll have WSL up and running in no time.