If you wanted to run Linux alongside Windows, the only option back in the day was to use a Virtual Machine. Sure, a dual-boot worked too, but it wasn’t quite what most users wanted.
In 2016, Microsoft introduced the Windows Subsystem for Linux (WSL) feature. This allowed users to run Linux tools natively on Windows, including the Linux terminal.
WSL 2, released in 2020, improves on its predecessor and offers much better performance and compatibility. The installation process has also been tremendously simplified, as demonstrated in this article.
How to Install Windows Subsystem (WSL2) for Linux?
First of all, if you’re interested in the differences between WSL1 and WSL2, the linked article covers things like their history and working mechanisms in detail. But the takeaway is that, barring a few exceptions, WSL2 is almost always the better option.
As for the prerequisites, there are 3 cases. In order to use the automated install method, Windows 10 version 2004 (Build 19041) or higher is the minimum requirement.
If performing a manual installation, the same requirement applies to ARM64 systems. For x64 systems, you need Version 1903 (Build 18362) or higher at the minimum.
Install WSL Command
Last year, Windows Insider preview builds introduced the ability to automate the entire installation process by just using the
wsl.exe – install command. The command automates the following tasks:
- Enabling the WSL and Virtual Machine Platform optional features
- Installing the latest Linux kernel
- Setting WSL 2 as the default
- Installing the default Linux distro
- Prompting a restart during the installation
In July 2021, this functionality was backported to older Windows versions as well, meaning all you need to do these days is execute the
wsl – install command in an elevated command prompt window.
There are a couple of catches, though. First, this method only works on Windows version 2004 or higher, as mentioned earlier. For older builds that support WSL2, manual installation is necessary.
Second, if no options are specified when using the command, it only installs the recommended features with the default distro (Ubuntu). Thus, we recommend getting familiar with some of the commands listed below:
- Use either of the following commands to check what Linux distros are available to install:
wsl – list – online
wsl -l -o
- Use the commands from above and note the distro names. Then, use either of the following commands to install WSL with a specific distro:
wsl – install – distribution
wsl – install -d
- Use the following command if you want to add more distros after the initial installation:
- Use the following command to update the WSL Linux kernel:
wsl – update
- Use this command if you need to rollback the kernel version:
wsl – update rollback
- Use this command to check general info regarding your WSL configuration:
wsl – status
- Finally, use this command to close the WSL 2 VM and all open distros:
wsl – shutdown
You might also be wondering what to do after you install WSL2. Well, it’s quite simple. First, you open the installed distro from the Start Menu. Next, you set up the admin account for this specific distro. This includes setting the username and password.
We recommend updating and upgrading the packages at this point, but beyond, you’re free to do as you please. If you feel lost, the getting started with WSL documentation from Microsoft is worth checking.
Manual WSL Installation
As stated, certain earlier Windows builds will require manual installation. The process is a bit longer, but we’re doing the same things as in the prior section. Here are the necessary steps:
- To start, reboot your PC and press the BIOS key (Function keys or Del) when booting.
- In the Advanced, CPU or similar section, enable the hardware virtualization option. Look for keywords like AMD-V, SVM, VT-d, VT-x, etc.
- Press the key shown on the screen to save the changes and exit (usually F10).
- In Windows, press Win + R, type
powershell, and press CTRL + Shift + Enter.
- Execute the following commands to enable the required components:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
- Now, download and install the Linux kernel update package. Depending on whether you’re using an x64-based system or an ARM64 machine, use the appropriate link. If you aren’t sure, the run command
msinfo32will be helpful.
- Now, enter the following command in PowerShell to set WSL 2 as the default version:
wsl – set-default-version 2
- Finally, go to the WSL Store in the Microsoft Store app. Choose your preferred distro here, and press Get.
- At this point, the WSL 2 installation is complete. We recommend checking the prior section for reference on what to do after the installation.
Troubleshooting Installation Errors
We’ve listed some common errors that users encounter during the WSL 2 installation in this section. If you’re facing some problem that’s not covered here, we recommend checking the troubleshooting guide from Microsoft for a more extensive guide.
- Error 0x8007019e: Make sure the WSL optional component is enabled.
- Error 0x80370102 or 0x80070003: Make sure hardware virtualization is enabled from the BIOS
- Error 0x80070003 installation failed: Ensure new programs are saved to your system drive. You can do this from Settings > System > Storage > More / Advanced Storage Settings > Change where new content is saved.
- Error: WSL 2 requires a kernel update: Update the WSL Linux Kernel. We’ve covered how to do this in both the automatic and manual installation sections. Additionally, make sure the Virtual Machine Platform component is enabled.
- Error: No installed distributions: If you haven’t already done so, obviously install a distro first. If you get said error despite this, make sure the distro was installed on the same Windows account you’re currently using.