Skip to content

WSL and WSL 2

Windows Subsystem for Linux is a product of Microsoft to emulate a Linux environment on top of Windows. There are two versions of the technology.

WSL 1

The oldest variant of the technology was originally known as WSL but is now more often denoted as WSL 1. It makes use of the kernel structure of the NT-based Windows versions (which is basically every version of Windows from Windows XP on), which can support subsystems that then can implement OS emulation. The original Windows NT kernel already had a POSIX subsystem as POSIX compatibility was a requirement to be able to sell Windows to certain USA government agencies. Already in the '90s a third party company, Softway Systems, developed a more extensive UNIX emulation, originally called OpenNT and later renamed to Interix. That technology required a re-compilation of UNIX software though. Microsoft acquired that technology and used it for a while in some Windows versions without much further development. However, it is rather likely that WSL 1 found its roots in that technology, though most sources claim that it started with an effort to try to run some Android applications on a version of Windows 10, a technology that was never released in its original form.

WSL 1 differs from OpenNT/Interix in that it offers Linux compatibility and runs native Linux binaries. It launched in 2016 with Windows 10.

It was possible to install several versions of Linux on top of the subsystem. Many but not all user-level features of those Linux distributions could then be supported, but the kernel used in those distributions was replaced by the WSL subsystem which was not a real Linux kernel.

WSL 2

WSL 2 takes a completely different approach. It actually runs a real Linux kernel with just a few modifications in a virtual machine. It also can run several Linux distributions which effectively run in containers but share the single kernel. Since it is using a full Linux kernel, compatibility is much better than in WSL 1 though there are also some disadvantages. In particular, as it runs a separate kernel, file access to Windows files is much slower than in WSL 1, but it has its own virtual file systems (per distribution) that are much faster than anything WSL 1 could offer.

The WSL 2 subsystem has now also been extended with support for Wayland graphics (and X11 on top of Wayland). This technology was first only available in Windows 11 but has since been ported to Windows 10 also. It works through the remote display protocol, but it is completely transparent to users. On some GPUs, GPU compute is now also supported.

In recent versions of Windows 10 and in Windows 11, WSL 2 can now be completely maintained from the Microsoft Store and updates happen completely independently from the regular Windows updates.

Linux distributions

Many Linux distributions are available in the Microsoft store. The author of this text has experimented with three of them:

  • Fedora Remix for WSL is a commercial product, though very cheap. It is produced by Whitewater Foundry whose main product is the more expensive Pengwin Enterprise distribution based on Red Hat that is oriented towards enterprise use.

    It is a nice distribution if you need something that is easy to install, not expensive, and has enough resemblance with clusters running Red Hat derived Linux distributions.

    It should be noted that AlmaLinux is also available in the Microsoft Store, but the author has no experience with that distribution. At the time of writing of these paragraphs, Rocky Linux, which seems to be the more popular CentOS replacement in HPC, was not available in the store.

  • There are various SUSE Linux distributions available in the store, with different upgrade policies. The author of these notes is using the openSUSE Leap distributions (e.g., openSUSE Leap 15.4) as the full Enterprise version has some licensing issues, while the Leap distributions are still more stable than the rolling Tumbleweed distribution.

    This is a good distribution if you want an environment that is close to the SUSE Linux based clusters, e.g., most Cray EX systems (including the European pre-exascale cluster LUMI).

  • There are also various packages for Ubuntu developed by Canonical itself, with different upgrade policies: one that follows the latest LTS release and packages for individual LTS releases that are still maintained. Originally only the LTS versions were offered for WSL but there is now also a version that offers a daily preview of new features as they are developed.

Integration with Windows

The Windows file systems are mounted in both versions of WSL. As WSL 1 uses more of an emulation approach, access to the Windows file systems can be done directly through the Windows kernel and is very fast. On WSL 2 access to the Windows file systems is a lot slower and more like accessing a network file system as the Linux kernel has to pass the file access requests to the Windows side. WSL 2 offers virtual file systems in each distribution though that are very fast, and some versions of Windows can now directly access files in those Linux distributions through explorer.

It is also possible to access the Windows ssh agent though this is not as easy as it sounds. The approach is different in WSL 1 and WSL 2. Pointers to the exact procedure are given in the "Issues - Using the Windows SSH Agent" section. It may require updating the Windows SSH agent to a more recent version which strangely enough is currently not done through Windows Update or the Microsoft Store.