Windows Subsystem for Linux 2 (WSL2) is being released soon with the May 2020 Update (Windows 10 2004) and comes with new features and performance improvements.
The Windows Subsystem for Linux feature allows you to install and run Linux distributions within Windows 10.
WSL version 1 (WSL1), though, used a Linux-compatible kernel that translates Linux system calls so they could communicate and work with the Windows NT kernel. This decreased the performance and made it difficult, if not impossible, to run certain Linux applications.
In Windows 10 version 2004, Microsoft has been testing new features for Windows Subsystem for Linux, which uses in-house built Linux kernel and full system call compatibility to run more Linux apps.
According to Microsoft, WSL 2 includes a new architecture that changes how these Linux binaries interact with Windows and hardware. The updated WSL will still provide the same user experience as WSL 1.
Real Linux kernel
Windows 10 version 2004 introduces a real Linux kernel for Windows Subsystem for Linux that will make full system call compatibility possible.
This would be the first time a Linux kernel is shipped with Windows. The kernel is based on the source available at kernel.org and it has been specially tuned for WSL 2 with optimized size and performance.
Microsoft says it will update Linux kernel through Windows Updates, which means you don’t have to manually download software or tool to patch Linux kernel with security fixes.
Microsoft says that WSL 2 uses virtualization technology to run the Linux kernel within a lightweight utility virtual machine, but it won’t be a traditional VM experience with limited resources and reduced integration.
WSL 2 does not have traditional virtual machine limitations such as reduced performance and limited resources.
The new virtualization technology also promises better Windows and Linux integration, fast boot times, and it won’t require VM configuration or management from your end.
WSL 2 is faster than WSL 1
In WSL 2, you will notice that file intensive operations like git clone, npm install, apt update, apt upgrade, and more would be “noticeably faster”.
Microsoft claimed that WSL 2 is up to 20x faster compared to WSL 1 when unpacking a zipped tarball. Likewise, it is around 2-5x faster when using git clone, npm install and cmake.
In version 2004 of Windows 10, Linux binaries use system calls execute functions such as accessing files, requesting memory, creating processes, etc.
With its own Linux kernel support, WSL 2 has access to full system call compatibility and it offers a whole new set of apps that you can run inside the container.
These improvements make WSL 2 much more powerful for you to run Linux apps.
WSL also comes with a long set of other improvements and bug fixes. Here’s a list of all changes and fixes in the new WSL update:
- Fix issue with handling of some Unicode characters
- Fix rare cases where distros could be unregistered if launched immediately after a build-to-build upgrade.
- Fix minor issue with wsl.exe –shutdown where instance idle timers were not cancelled.
- Improve memory performance of WSL utility VM. Memory that is no longer in use will be freed back to the host.
- Fix input relay to handle cases where stdin is a pipe handle that is not closed [GH 4424]
- Make the check for wsl$ case-insensitive.
- Use cache=mmap as the default for 9p mounts to fix dotnet apps
- Fixes for localhost relay [GH 4340]
- Introduce a cross-distro shared tmpfs mount for sharing state between distros
- Fix restoring persistent network drive for wsl$
- Update Linux kernel to 4.19.81
- Change the default permission of /dev/net/tun to 0666 [GH 4629]
- Tweak default amount of memory assigned to Linux VM to be 80% of host memory
- Fix interop server to handle requests with a timeout so bad callers cannot hang the server
- Clear the signal mask before launching the processes
- Handle creation of /etc/resolv.conf symlink when the symlink is non-relative
- Use a memory cgroup to limit the amount of memory used by install and conversion operations [GH 4669]
- Make wsl.exe present when the Windows Subsystem for Linux optional component is not enabled to improve feature discoverability.
- Change wsl.exe to print help text if the WSL optional component is not installed
- Fix race condition when creating instances
- Create wslclient.dll that contains all command line functionality
- Prevent crash during LxssManagerUser service stop
- Fix wslapi.dll fast fail when distroName parameter is NULL