Table of Contents
Windows Subsystem for Linux WSL1
In this post, how to upgrade WSL 1 to WSL 2 in Windows 10, 11. Before you begin, please note WSL 2 is only available in:
- Windows 11
- Windows 10, version 1903, build 18362 or later.
The primary reasons to update from WSL 1 to WSL 2 are to:
- increase file system performance,
- support full system call compatibility.
Get the list of installed distributions:
PS C:\> wsl -l -v NAME STATE VERSION * Ubuntu Stopped 1 Debian Stopped 1
Enable Virtual Machine Platform
1. First, you need enable Virtual Machine Platform in order to run WSL 2. You can enable it using PowerShell or using Turn on Windows Features.
2. Once done, restart your computer to take the changes go into effect.
PS C:\> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all Deployment Image Servicing and Management tool Version: 10.0.19041.844 Image Version: 10.0.19043.2075 Enabling feature(s) [==========================100.0%==========================] The operation completed successfully. Restart Windows to complete this operation. Do you want to restart the computer now? (Y/N)
Install the Linux kernel update package
The Linux kernel in WSL 2 is built by Microsoft from the latest stable branch, based on the source available at kernel.org. This kernel has been specially tuned for WSL 2, optimizing for size and performance to provide an amazing Linux experience on Windows.
Let’s download then install the Linux kernel update package https://aka.ms/wsl2kernel
Set default version
Open PowerShell and run this command to set WSL 2 as the default version when installing a new Linux distribution:
PS C:\> wsl --set-default-version 2 For information on key differences with WSL 2 please visit https://aka.ms/wsl2 The operation completed successfully.
Now, you can using this command wsl -l -o to get the valid distributions to install. Then install a distro using wsl –install command.
PS C:\> wsl -l -o The following is a list of valid distributions that can be installed. Install using 'wsl --install -d <Distro>'. NAME FRIENDLY NAME Ubuntu Ubuntu Debian Debian GNU/Linux kali-linux Kali Linux Rolling openSUSE-42 openSUSE Leap 42 SLES-12 SUSE Linux Enterprise Server v12 Ubuntu-16.04 Ubuntu 16.04 LTS Ubuntu-18.04 Ubuntu 18.04 LTS Ubuntu-20.04 Ubuntu 20.04 LTS PS C:\> wsl --install -d kali-linux Downloading: Kali Linux Rolling Installing: Kali Linux Rolling Kali Linux Rolling has been installed. Launching Kali Linux Rolling... PS C:\> wsl -l -v NAME STATE VERSION * Ubuntu Stopped 1 kali-linux Installing 2 Debian Stopped 1
If you’ve version 1 installed distros, you can upgrade them to version 2 using –set-default parameter.
PS C:\> wsl --set-version ubuntu 2 Conversion in progress, this may take a few minutes... For information on key differences with WSL 2 please visit https://aka.ms/wsl2 Conversion complete. PS C:\> wsl --set-version debian 2 Conversion in progress, this may take a few minutes... For information on key differences with WSL 2 please visit https://aka.ms/wsl2 Conversion complete. PS C:\> wsl -l -v NAME STATE VERSION * Ubuntu Stopped 2 kali-linux Stopped 2 Debian Stopped 2
In some cases, you can simply upgrade WSL 1 to WSL 2 using this command.
PS C:\> wsl --update Checking for updates... Downloading updates... Installing updates... This change will take effect on the next full restart of WSL. Kernel version: 18.104.22.168