Windows Subsystem for Linux (WSL) is a fantastic Dev and Test environment, providing seamless integration for Linux apps and shells running on Windows 10. This post is a quick summary of the manual steps to enable WSL2 in Windows 10.

Windows Insider Builds

At the time of writing, Microsoft is making it much simpler to install and enable WSL2 using a single command. This option is only available in Insider Builds 20262 and higher.

wsl --install

For the stable release versions of Windows 10, the following manual steps are required.

Enable virtualization support

This is separate to the Hyper-V optional feature, but does use the same architecture.

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Enable WSL feature

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

WSL kernel update package

This is required because Microsoft removed the previously included Linux kernel from Windows. It now gets updated and patched through Windows Update

Download and install the update package

Set the default version

Make sure everything is version 2

wsl --set-default-version 2

Install the required distro

Ubuntu is the most reliable on Windows at the time of writing

Ubuntu 20.04 LTS

Create username

Start the distro from the Start Menu shortcut. When prompted, specify a username and password.

The user is automatically added to the Sudo group.

Update packages in the distro

Launch Ubuntu and start a terminal shell

sudo apt-get update

sudo apt-get upgrade

Check you are running version 2

Windows 10 PowerShell:

wsl --list -v

  NAME                   STATE           VERSION
* docker-desktop-data    Running         2
  Ubuntu-20.04           Running         2
  docker-desktop         Running         2

Location of the .vhdx file

The virtual disk containing the Linux OS is located here:

%LOCALAPPDATA%\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx



This article was originally posted on Write-Verbose.com