If you want to try out the improved Windows Subsystem for Linux 2 (aka WSL 2) included in the latest Windows update you’ll need to roll your sleeves up — but don’t worry: we cover everything you need to do in this post.
WSL 2 is a major upgrade over the original version of WSL Microsoft introduced back in 2017. WSL 2 isn’t just a version bump, either. It’s faster, more versatile, and uses a real Linux kernel. Future Linux kernel updates will be released as Windows 10 software updates — which is kinda crazy when you think about it!
Microsoft’s goal in creating WSL 2 is to boost performance. And the best way to do that? Add full system call compatibility, i.e. put a real Linux kernel at the heart of things.
“[This] new architecture presents a better platform for the WSL team to deliver features that make WSL an amazing way to run a Linux environment in Windows,” say Microsoft of the tech.
The crazy shows no sign of abating just yet as Microsoft will make possible to run desktop Linux apps on Windows 10 and leverage GPU-intensive tasks later this year!
For now, WSL 2 is something you use from the command line in a terminal emulator (like the open source Windows Terminal app Microsoft has built).
Install WSL 2 on Windows 10
To install WSL 2 on Windows 10 you need the following things:
- Windows 10 May 2020 Update
- A computer with Hyper-V Virtualization support
The Windows 10 May 2020 update was released in May 2020 (obviously) but not every device is able to upgrade right away. To see if the Windows 10 May 2020 Update is available on your computer go to Settings > Update & Security > Windows Update.
Advanced (and impatient) Windows users can force install the Windows 10 May 2020 update, just keep in mind that you may encounter missing drivers, GUI glitches, or other hardware hiccups if you go this route.
Technically you can install WSL 2 on an “insider” build of Windows 10 build 18917 or later. I’m not too familiar with how the “insider” build system works so just be aware that the rest of this post is based on using the feature in a regular stable version of Windows.
Your computer also needs to support Hyper-V Virtualization to run WSL 2. You can check your Hyper-V support to be sure.
If you do not meet both of these requirements then you cannot install or enable WSL 2 — but you can use WSL 1.
The process of enabling WSL 2 on Windows 10 is this:
- Enable WSL
- Enable ‘Virtual Machine Platform’
- Set WSL 2 as default
- Install a distro
I’ll walk through each of these steps in turn using the PowerShell app you can find in the Windows Start Menu. While it is possible to nebula WSL 1 using a GUI, it’s simple much faster to use the command line — and since WSL is a CLI tool, it kinda makes sense too.
1. Enable WSL
Regardless of which version of WSL you want to use you first need to enable it. To do this open the PowerShell tool as an Administrator and run the command below. Be careful not to mistype or leave out any character in the command:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Only want to use WSL 1? You can skip to step 4.
2. Enable ‘Virtual Machine Platform’
WSL 2 requires Windows 10’s “Virtual Machine Platform” feature to be enabled. This is separate from Hyper-V and hands some of the more interesting platform integrations available in the new version of the Windows Subsystem for Linux.
To enable Virtual Machine Platform open PowerShell as Administrator and run:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
To ensure all of the relevant bits and pieces fall neatly in to place you should restart your system at this point or you may find that things don’t work as intended.
3. Set WSL 2 as default
Open PowerShell as Administrator and run this command to set WSL 2 as the default version of WSL:
wsl --set-default-version 2
You can (at any time) configure a distro to run in WSL 1 mode if you need to.
4. Install a distro
With WSL and the necessary virtualisation tech all in place all that is left for you to do is pick and install a Linux distro from the Microsoft Store.
Several different distros are available, including OpenSUSE, Pengwin, Fedora Remix, and Alpine Linux. But my personal recommendation is (naturally) Ubuntu 20.04 LTS (though 18.04 LTS and 16.04 LTS are also available).
To install Ubuntu on Windows 10 open the Microsoft Store app, search for “Ubuntu 20.04”, and hit the “Get” button:
Whilst you in the Microsoft Store I highly recommend that you also install the open source Windows Terminal app. This tool is designed to give you the best possible WSL experience:
5. Use WSL 2
When you installed Ubuntu (or a different Linux distro) a shortcut was added tot he Start Menu. Use this to “open” Ubuntu (or whichever distro you chose). The first time you run the distro things will seem a little slow. This is expected; the distro has to unpack and decompress all of its contents — just don’t interrupt the process.
You will also be promoted to set a username and password for use on the distro. Try to pick something you won’t forget.