WSL2: meet the Windows Subsystem for Linux 2

The Windows Subsystem for Linux 2 (WSL2) is probably the simplest and most efficient solution to use Linux applications in Windows. WSL2 allows access to Linux tools and applications directly from the well-known Windows environment which makes it a good option for developers. Due to its completely revised architecture compared to WSL1, WSL2 is more performant than other options for using Linux tools in Windows.

What is WSL2?

WSL2, which was released in early 2020, is the further development of the Windows Subsystem for Linux (WSL1). Linux is an open source operating system and is, therefore, different to Windows, which is developed and distributed as a commercial product. Linux can be a great option due to the wide range of developer tools and other software packages available free of charge.

What are the differences between WSL2 and its predecessor?

The fundamental difference between WSL2 and its predecessor lies in the architecture of the software. While WSL1 provided a compatibility layer for translating code execution between Windows and Linux, WSL2 relies on the virtualisation of a Linux operating system. The virtual machine used for this runs on the native Windows hypervisor, hyper-V.
While the functionality of the Linux interface provided by WSL1 was limited, WSL2 uses a complete Linux kernel. This is a kernel specially optimised for WSL2 both in terms of size and performance and is based on the stable original code from ‘kernel.org’. In use, this is reflected in the faster code execution by a factor of about two to twenty. Furthermore, WSL2 requires less memory than the previous version. That the kernel is maintained as part of the regular Windows updates makes it more convenient for its users, too.
Since WSL1 uses a translation layer to mediate between Linux and Windows, some specialised Linux software is left out in this version of WSL. In contrast, WSL2’s kernel virtualisation performs full system call compatibility. In practice, this means that even complex software like Docker can be operated within WSL2. Furthermore, the GPU can be accessed from the Linux environment, which is particularly useful for applications with large datasets such as machine learning and data science.
Even though the use of WSL2 is recommended on modern systems, both versions can be operated in parallel. For each Linux distribution, it is possible to specify individually which WSL version is to be used.

What are the requirements for using WSL2?

The system requirements for using WSL2 depend on the processor installed in your machine:
  • For x64 systems, you need at least version 1903 with build 18362 or later.
  • For ARM64 systems, you need at least version 2004 with build 19041 or later.
If you are not sure which Windows edition and version you are running, you can check this with the following steps:
  • Press the Windows logo key + [R], type ‘winver’ in the text box that appears and press [Enter].
  • Alternatively, click Start > Settings > System > Info > Windows Specification and read the values there.

How can I use WSL2 on my own system?

In principle, there are two methods for using WSL2 on your system. We will show the two different methods in detail, depending on your situation:
  1. If you have not yet installed a Windows subsystem for Linux, install both the WSL2 on your system and set up a Linux distribution.
  2. If you are already using WSL1, install WSL2 and upgrade the existing Linux distributions.
To set up the WSL2 on your system, you need the Windows PowerShell. Note that you must start PowerShell as an administrator to perform the installation. Copy the commands shown to the PowerShell prompt and run them there.

WSL2 activation and installing a Linux distribution

If you do not have WSL1 installed on your system, follow our instructions to install both a WSL2 and a Linux distribution:

Step 1: Activate the Windows-Subsystem for Linux

Copy and run the following command from the PowerShell prompt:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Step 2: Enable virtual computer functions

Copy and run the following command from the PowerShell prompt:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Step 3: Install update package for the Linux Kernel

First, download the appropriate installation package for your system. Then run the installer. Choose the appropriate package depending on your computer processor:

Step 4: Set WSL2 as standard

Copy and run the following command from the PowerShell prompt:
wsl --set-default-version 2

Step 5: Restart

Restart your computer.

Step 6: Choose the Linux-Distribution and install

Open the Microsoft Store and search for ‘Linux’. You will see a selection of available Linux distributions.
Click on the Linux distribution and then on ‘Install’. If you are not sure which distribution is right for you, we recommend installing Ubuntu Linux 20.04 LTS.
After the installation is complete, click ‘Start’.

Step 7: Set up Linux-Distribution

In the next window, the packages will be downloaded and unpacked. This may take a few minutes. Finally, you will be prompted to specify a username and a password for the new Linux installation.
Note
You can run several Linux distributions in parallel with WSL. To do this, create a separate user account for each distribution.

Upgrading an existing Linux distribution from WSL1 to WSL2

Provided you are already using WSL1 and have set up a Linux installation, go through steps 2-4 from the instructions above first. Then use the following PowerShell command to switch your installed Linux distribution to WSL2:
wsl --set-version <distribution> 2</distribution>
The <distribution> placeholder must be replaced with the name of an installed Linux distribution. Use the following PowerShell command to display a list of installed Linux distributions and view their names:

wsl --list --verbose
Note
The settings for an installed Linux distribution are stored in a configuration file ‘wsl.conf’. This file will keep working after switching to WSL2.

Concluding feature comparison between WSL2 and WSL1

As you have seen, using WSL2 offers many advantages over the previous version. To conclude this introduction to WSL2, we have summarised the similarities and differences of the two versions for you:
Feature WSL1 WSL2
Provides integration between Windows and Linux
Fast start-up of the Linux environment
High performance and low resource requirements
Based on virtual machine (VM)
Includes full Linux kernel
Provides full system call compatibility
Allows parallel use of VMware and VirtualBox
Allows use across operating system file systems
Was this article helpful?
Page top