May 24

The Windows Subsystem for Linux (WSL) is a feature of the Windows operating system that enables you to run a Linux file system, along with Linux command-line tools and GUI apps, directly on Windows, alongside your traditional Windows desktop and apps. You can now preview Windows Subsystem for Linux (WSL) support for running Linux GUI applications (X11 and Wayland) on Windows in a fully integrated desktop experience. Now we have 2 different WSL here. In this article, let’s try to see how both WSL 1 WSL 2 are different from each other.

Comparing features

As you can tell from the comparison table above, the WSL 2 architecture outperforms WSL 1 in several ways, with the exception of performance across OS file systems, which can be addressed by storing your project files on the same operating system as the tools you are running to work on the project.

WSL 2 is only available in Windows 11 or Windows 10, Version 1903, Build 18362 or later. Check your Windows version by selecting the Windows logo key + R, type winver, select OK. (Or enter the ver command in Windows Command Prompt). You may need to update to the latest Windows version. For builds lower than 18362, WSL is not supported at all.

WSL 2 enables Linux GUI applications to feel native and natural to use on Windows.

  • Launch Linux apps from the Windows Start menu
  • Pin Linux apps to the Windows task bar
  • Use alt-tab to switch between Linux and Windows apps
  • Cut + Paste across Windows and Linux apps

You can now integrate both Windows and Linux applications into your workflow for a seamless desktop experience.

What’s new in WSL 2

WSL 2 is a major overhaul of the underlying architecture and uses virtualization technology and a Linux kernel to enable new features. The primary goals of this update are to increase file system performance and add full system call compatibility.

WSL 2 architecture

VM experience is often slow to boot up, isolated, consumes a lot of resources, and requires your time to manage it. WSL 2 does not have these attributes. WSL 2 provides the benefits of WSL 1, including seamless integration between Windows and Linux, fast boot times, a small resource footprint, and requires no VM configuration or management. While WSL 2 does use a VM, it is managed and run behind the scenes, leaving you with the same user experience as WSL 1.

Integration of Linux kernel

The Linux kernel in WSL 2 is built by Microsoft from the latest stable branch, based on the source available at kernel.org. This kernel has been specially tuned for WSL 2, optimizing for size and performance to provide an amazing Linux experience on Windows. The kernel will be serviced by Windows updates, which means you will get the latest security fixes and kernel improvements without needing to manage it yourself. The WSL 2 Linux kernel is open source.

Increased file IO performance

File intensive operations like git clone, npm install, apt update, apt upgrade, and more are all noticeably faster with WSL 2.

The actual speed increase will depend on which app you’re running and how it is interacting with the file system. Initial versions of WSL 2 run up to 20x faster compared to WSL 1 when unpacking a zipped tarball, and around 2-5x faster when using git clone, npm install and cmake on various projects.

Full system call compatibility

Linux binaries use system calls to perform functions such as accessing files, requesting memory, creating processes, and more. Whereas WSL 1 used a translation layer that was built by the WSL team, WSL 2 includes its own Linux kernel with full system call compatibility. Benefits include:

  • A whole new set of apps that you can run inside of WSL, such as Docker and more.
  • Any updates to the Linux kernel are immediately ready for use. (You don’t have to wait for the WSL team to implement updates and add the changes).

How to install WSL and update to WSL 2

Before installing any Linux distributions on Windows, you must enable the “Windows Subsystem for Linux” optional feature.

Open PowerShell as Administrator and run:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

To only install WSL 1, you have to restart your machine and move on to install your Linux distribution of choice. You can download it from the Windows store.

To update to WSL 2, you must have a running Windows 10, updated to version 2004, Build 19041 or higher.Before installing WSL 2, you must enable the “Virtual Machine Platform” optional feature.

Open PowerShell as Administrator and run:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Restart your machine to complete the WSL install and update to WSL 2.

To activate WSL 2 you need to update the kernel component. You can do it by visiting here and install the update by following the steps.

You can check the WSL version assigned to each of the Linux distributions you have installed by opening the PowerShell command line and entering the command (only available in Windows Build 19041 or higher): wsl -l -v

wsl --list --verbose

To set a distribution to be backed by either version of WSL please run:

wsl --set-version <distribution name> <versionNumber>

Make sure to replace <distribution name> with the actual name of your distribution and <versionNumber> with the number ‘1’ or ‘2’. You can change back to WSL 1 at any time by running the same command as above but replacing the ‘2’ with a ‘1’.

If you want to make WSL 2 your default architecture you can do so with this command:

wsl --set-default-version 2

Conclusion

Due to the limitations in WSL1 Microsoft re-invented the WSL1 and introduced WSL2 which is available in Windows 10 version 2004 update. Instead of using a compatibility layer which converts Linux system calls to windows system calls, WSL2 offers its own isolated Linux kernel running on a thin version of the Hyper-V hypervisor. And this gives WSL2 much more opportunity to handle things better than WSL1. Hopefully this guide and informations will help you to understand why WSL2 is a better choice over WSL1.

Tags: , ,