How To Install WSL 2 (Windows Subsystem for Linux) with Ubuntu On Windows 10

How To Install WSL 2 (Windows Subsystem for Linux) with Ubuntu On Windows 10

It provides all the steps required to install Windows Subsystem for Linux i.e. WSL 2 with Ubuntu 20.04 LTS on Windows 10.

September 18, 2021

Windows Subsystem for Linux i.e. WSL allows us to run a Linux environment directly on Windows 10. We can use the Linux OS on Windows just like we are using the actual Linux OS. Also, there is no need for dual boot or any resource-intensive applications like Hyper-V, VirtualBox, Parallels, WMware, or Vagrant. This tutorial provides all the steps required to install Windows Subsystem for Linux i.e. WSL 2 with Ubuntu 20.04 LTS on Windows 10.

Notes: This tutorial does not cover the steps to install WSL 2 on Windows 10 for the members of the Windows Insider Program. It covers the manual installation steps to install WSL 2.

Prerequisites

This tutorial assumes that you have the appropriate Windows build in order to install or upgrade to WSL 2. The minimum system requirements for installing WSL 2 on Windows 10 are listed below.

X64 Systems - Version 1903 or higher, with Build 18362 or higher

ARM64 Systems - Version 2004 or higher, with Build 19041 or higher

You can always check your Windows version and build by right-clicking the Start Menu and choose Run as shown in Fig 1.

Install Windows Subsystem For Linux WSL 2 on Windows 10 - Check Version

Fig 1

Now type winver as shown in Fig 2 and hit Enter Key. It should show the Windows 10 version and Build as shown in Fig 3.

Install Windows Subsystem For Linux WSL 2 on Windows 10 - Check Version

Fig 2

Install Windows Subsystem For Linux WSL 2 on Windows 10 - Check Version

Fig 3

The version on my Windows 10 - X64 system is 20H2 and Build is 19042 which is good to install WSL 2.

Enable Virtual Machine and Windows Subsystem for Linux On Windows 10

After confirming the minimum requirements to install WSL 2, we will enable the Virtual Machine feature on Windows 10 using the command shown below. Open PowerShell as Administrator and execute the command.

# Enable Virtual Machine Feature
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

It should show the success message as shown in Fig 4.

Similarly, enable the Windows Subsystem for Linux feature on Windows 10 using the command as shown below. Use PowerShell as Administrator to execute the command.

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

Install Windows Subsystem For Linux WSL 2 on Windows 10 - Enable Virtual Machine Feature

Fig 4

Download Linux Kernel update Package

In this step, we will download and install the most recent version of the Linux Kernel update Package using the Official Download for X64. Run the installer by double-clicking it after completing the download. It might show a security warning as shown in Fig 5.

Install Windows Subsystem For Linux WSL 2 on Windows 10 - WSL Installation Warning

Fig 5

Click the OK Button to continue the installation. The installer will show the Welcome Screen as shown in Fig 6.

Install Windows Subsystem For Linux WSL 2 on Windows 10 - WSL Installation Warning

Fig 6

Now click the Next Button. It might ask for system permission. Allow the installer to continue the installation. It will show the success message after completing the installation as shown in Fig 7.

Install Windows Subsystem For Linux WSL 2 on Windows 10 - WSL Installed

Fig 7

Now click the Finish Button to close the installer. Also, set the WSL 2 as your default version using the command shown below. Use PowerShell as administrator to execute the command.

# Change WSL Version
wsl --set-default-version 2

# Output
For information on key differences with WSL 2 please visit https://aka.ms/wsl2

This completes the installation of WSL 2 on Windows 10.

Install Ubuntu 20.04 LTS

In this step, we will install Ubuntu 20.04 LTS on Windows 10 by downloading the distribution from Microsoft Store. Open Microsoft Store and search for Linux. It lists all the available Linux distributions as shown in Fig 8.

Install Windows Subsystem For Linux WSL 2 on Windows 10 - Download Ubuntu 20.04 LTS

Fig 8

Now, click the Ubuntu 20.04 LTS option as highlighted in Fig 8. It shows the details of Ubuntu 20.04 LTS as shown in Fig 9.

Install Windows Subsystem For Linux WSL 2 on Windows 10 - Download Ubuntu 20.04 LTS

Fig 9

Click the Get Button to start downloading Ubuntu 20.04 LTS for WSL 2. It will show the download progress as shown in Fig 10.

Install Windows Subsystem For Linux WSL 2 on Windows 10 - Download Ubuntu 20.04 LTS Progress

Fig 10

After completing the download and installation, it will ask to launch Ubuntu 20.04 LTS as shown in Fig 11.

Install Windows Subsystem For Linux WSL 2 on Windows 10 - Launch Ubuntu 20.04 LTS

Fig 11

Click the Launch Button to launch Ubuntu 20.04 LTS. It might show an error on the first launch as mentioned below and in Fig 12.

Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0xc03a001a
Error: 0xc03a001a The requested operation could not be completed due to a virtual disk system limitation.  Virtual hard disk files must be uncompressed and unencrypted and must not be sparse.

Press any key to continue...

Install Windows Subsystem For Linux WSL 2 on Windows 10 - Launch Error Ubuntu 20.04 LTS

Fig 12

Close the Ubuntu window, locate the CanonicalGroupDirectory as shown in Fig 14, right-click the LocalState directory, select Advanced Options, and uncheck Compress contents to save disk space option.

13-install-windows-subsystem-for-linux-wsl-2-on-windows-10-launch-error-ubuntu-20-04-lts

Fig 13

Now, again launch Ubuntu 20.04 LTS. It will take some time for the first launch. The subsequent launches will be faster. It will ask to set the default username and password on successful launch as shown in Fig 14.

Install Windows Subsystem For Linux WSL 2 on Windows 10 - Configure Ubuntu 20.04 LTS

Fig 14

After providing the default username and password, it will start the Ubuntu 20.04 LTS machine as shown in Fig 15.

Install Windows Subsystem For Linux WSL 2 on Windows 10 - Ubuntu 20.04 LTS

Fig 15

This completes the installation of Ubuntu 20.04 LTS using Windows Subsystem for Linux i.e. WSL 2. We can also confirm Ubuntu 20.04 using the command prompt as shown below.

# Check Installed Distributions
wsl --list

# Output
Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)

# Check Installed Distributions with State
wsl --list --verbose

# Output
NAME STATE VERSION
* Ubuntu-20.04 Running 2

We can also switch the WSL versions as shown below.

# Switch Ubuntu 20.04 to WSL 2
wsl --set-version Ubuntu-20.04 2

# Switch Ubuntu 20.04 to WSL 1
wsl --set-version Ubuntu-20.04 1

The Ubuntu can be terminated using the terminate command as shown below.

# Terminate Ubuntu
wsl --terminate Ubuntu-20.04

# Check State
wsl --list --verbose

# Output
NAME STATE VERSION
* Ubuntu-20.04 Stopped 2

Using Windows Terminal

We can also access the Ubuntu 20.04 LTS installed by us using the Windows Terminal. You can also follow How To Install Windows Terminal on Windows 10.

Now launch Ubuntu 20.04 LTS using WSL 2 in a new tab of Windows Terminal as shown in Fig 16.

Install Windows Subsystem For Linux WSL 2 on Windows 10 - Windows Terminal

Fig 16

Browse Drives

We can browse the available windows partitions using the command >cd /mnt/<drive letter>/<the path> from either Ubuntu 20.04 launched directly from the Start Menu or launched using the Windows Terminal as shown in Fig 17.

Install Windows Subsystem For Linux WSL 2 on Windows 10 - Browse Directories

Fig 17

Summary

This tutorial provided all the steps required to install Windows Subsystem for Linux i.e. WSL 2 on Windows 10. It also provided all the steps required to install Ubuntu 20.04 LTS on Windows 10 using WSL 2.

Write a Comment
Click the captcha image to get new code.
Discussion Forum by DISQUS