Microsoft is releasing the next major updated to Windows 10, commonly known as “Windows 10 2004 (20H1) Update” on May 28, 2020. This update include many feature and improvement over the last release, but the most important feature from a developer perspective is WSL 2 (Windows Subsystem for Linux version 2) as it include many feature which will make a developers life much easier.
What is Windows Subsystem for Linux (WSL) ?
WSL is a windows 10 feature which enable you to run native Linux command-line tools directly on your windows desktop, with access to all your file stored inside your windows desktop.
What’s Different in WSL 2 ?
WSL 1 works on translation based approach, so when ever a Linux binary made any system call it was converted to windows system call using WSL-1 translation layer and request made to Windows NT kernel, and when Windows kernel sends any response back WSL-1 translation layer converts the response into a format which Linux binaries will understand, because of which we didn’t have 100% system call compatibility.
WSL 2 works on virtualization based approach, it puts your distro and actual Linux kernel maintained by Microsoft inside a light-weight utility VM. So, in WSL 2 when ever a system call is made it directly interacts with this kernel eliminating the need of a translation layer. Now, when the translation layer is out of the picture WSL 2 has significant improvement over file IO performance and 100% system call compatibility as it uses actual Linux kernel. This opens up a possibility for future, running an Linux GUI based application on windows.
How To Install WSL 2 ?
- Make sure your windows is updated to 2004 version.
- Search for Turn Windows Features on or off
- Enable the features shown in the image
- Restart your PC, when asked to.
- Now WSL is installed in your PC
- If you don’t have any distros, you can install it from Microsoft Store
- To use WSL 2, open Windows PowerShell
- Use the command listed below
List all distros
wsl -l -v
Change WSL version to 2 for a distro
wsl --set-version <Distro-Name> 2
Change WSL version to 1 for a distro
wsl --set-version <Distro-Name> 1
Set WSL 2 as default version
wsl --set-default-version 2
Hope this article was useful for you, thanks reading.