With release of Windows 10 Build 18917, Microsoft introduced WSL 2 to Insiders, the Windows Subsystem for Linux 2. It ships a real Linux kernel with Windows that will make full system call compatibility possible. This is the first time a Linux kernel is shipped with Windows.
WSL 2 is a new version of the architecture that powers the Windows Subsystem for Linux to run ELF64 Linux binaries on Windows. This new architecture changes how these Linux binaries interact with Windows and your computer’s hardware, but still provides the same user experience as in WSL 1 (the current widely available version).
The architectural changes in WSL 2
WSL 2 uses the latest and greatest in virtualization technology to run its Linux kernel inside of a lightweight utility virtual machine (VM). However, WSL 2 will NOT be a traditional VM experience. When you think of a VM, you probably think of something that is slow to boot up, exists in a very isolated environment, consumes lots of computer resources and requires your time to manage it. WSL 2 does not have these attributes. It will still give the remarkable benefits of WSL 1: High levels of integration between Windows and Linux, extremely fast boot times, small resource footprint, and best of all will require no VM configuration or management.
There are some user experience changes that you’ll notice when you first start using WSL 2. Here are the two most important changes in this initial preview.
Place your Linux files in your Linux root file system
Make sure to put the files that you will be accessing frequently with Linux applications inside of your Linux root file system to enjoy the file performance benefits. Microsoft understands that they have spent the past three years telling you to put your files into your C drive when using WSL 1, but this is not the case in WSL 2. To enjoy the faster file system access in WSL 2 these files must be inside of the Linux root file system. It is now possible for Windows apps to access the Linux root file system (like File Explorer! Try running:
explorer.exe / in your bash shell and see what happens) which will make this transition significantly easier.
Access your Linux network applications with a dynamic IP address in initial builds
WSL 2 includes a huge architecture change using virtualization technology, and the networking support is still a work in progress. Since WSL 2 now runs in a virtual machine, you will need to use that VM’s IP address to access Linux networking applications from Windows, and vice versa you will need the Windows host’s IP address to access Windows networking applications from Linux. Soon, WSL 2 will include the ability to access network applications with
localhost. You can find full details and steps on how to do this in the documentation here.
To read more about the user experience changes please see the following documentation: User Experience Changes Between WSL 1 and WSL 2.
New WSL Commands
There are some new commands to help you control and view your WSL versions and distros.
wsl --set-version <Distro> <Version>
Use this command to convert a distro to use the WSL 2 architecture or use the WSL 1 architecture.: the specific Linux distro (e.g. “Ubuntu”)
: 1 or 2 (for WSL 1 or 2)
wsl --set-default-version <Version>
Changes the default install version (WSL 1 or 2) for new distributions.
Immediately terminates all running distributions and the WSL 2 lightweight utility virtual machine. There could be cases where you would want to shut it down manually, and this command lets you do that by terminating all distributions and shutting down the WSL 2 VM.
wsl --list --quiet
Only list the distribution names.This command is useful for scripting since it will only output the names of distributions you have installed without showing other information like the default distro, versions, etc.
wsl --list --verbose
Shows detailed information about all the distributions.This command lists the name of each distro, what state the distro is in, and what version it is running. It also shows which distributions is default with an asterisk.
See how to install WSL 2 HERE.