How to Change WSL Default Version to WSL 2 in Windows 10 or Windows 11?
Windows Subsystem for Linux (WSL) provides a way to run a Linux environment directly on a Windows machine. With the introduction of WSL 2, which offers improved performance and compatibility compared to WSL 1, it is beneficial to set WSL 2 as the default version. In this blog post, we will guide you through the step-by-step process of changing the default WSL version to WSL 2 in Windows 10 or Windows 11.
Open PowerShell as Administrator and issue the following command to guarantee that all future WSL Linux distributions utilize WSL 2 rather than WSL 1.
wsl --set-default-version 2
You may encounter the following error: WSL 2 requires a kernel component upgrade. Install Kernel Updates and perform the wsl --set-default-version 2 command again if this is the case.
If you do not wish to use Windows Subsystem for Linux 2 as the default version for whatever reason, use the following command:
wsl --set-default-version 1
Prerequisites:
Before you begin, ensure that you have:
- Windows 10 version or Windows 11 version is required.
- Administrative access to your Windows machine.
- An active internet connection.
Step 1: Enable WSL and Virtual Machine Platform Features
To use WSL 2, you need to enable the necessary Windows features. Open PowerShell as an administrator and run the following commands one by one:
wsl --install
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
These commands enable both WSL and the Virtual Machine Platform feature.
How to Install Ubuntu on Windows using WSL (Windows Subsystem for Linux)
Step 2: Install a Linux Distribution
Next, you need to install a Linux distribution from the Microsoft Store. Open the Microsoft Store and search for your preferred Linux distribution (e.g., Ubuntu, Debian, or openSUSE). Click on the distribution and select "Install."
Step 3: Set WSL Version for the Linux Distribution
Once the Linux distribution is installed, open PowerShell as an administrator and run the following command to set the default WSL version to 2:
wsl --set-version <DistributionName> 2
For example: wsl --set-version Ubuntu 2
Replace <DistributionName> with the actual name of the installed Linux distribution (e.g., Ubuntu, Debian). Note that the name is case-sensitive.
Step 4: Verify WSL Version Change
To verify that the default WSL version has been successfully changed to WSL 2, run the following command in PowerShell:
wsl --list --verbose
The command will provide a list of installed Linux distributions and their versions. WSL 2 should now be the default version.
Step 5: Optional: Set WSL 2 as the Default Version for Future Installations
To ensure that future installations of Linux distributions use WSL 2 by default, run the following command in PowerShell:
wsl --set-default-version 2
This command makes WSL 2 the default version for all newly installed Linux distributions.
Finally, by following these instructions, you can simply change the default WSL version in Windows 10 or Windows 11 to WSL 2. WSL 2 provides increased speed and compatibility, allowing you to operate easily with a Linux environment on your Windows system.
Please keep in mind that the particular actions and instructions described in this blog may differ significantly depending on the version of Windows you are using. If you need special instructions for your Windows version, consult the official Microsoft manual.