Install Linux On Windows 10 Using (wsl1 or wsl2) Update 2021- Best Ways In 2021

Install Linux On Windows 10

Either you’re keen on or hate it, but you won’t’ be ready to ignore it. Yes, that’s the facility of Open source and Linux. during this tutorial, I will be able to show you “How to put in Linux on Windows 10 using WSL1“. and explain “How to update WSL1 to WSL2 kernel in Windows 10“, just in case you have already got WSL1 installed.

Have you ever imagined, Microsoft “The market dominator” will handshake with Open source and can support its development?

Whatever you never thought is now possible on Windows, In earlier days, if I want to run Rsync or the other Linux utility, Cygwin was the solution to most of the issues.

Nowadays there are options like VMware Workstation Player, Virtual box, and lots of other Virtualization Software to put in Linux as guest OS but Microsoft is thinking differently.

Microsoft has introduced WSL2 (Windows Subsystem for Linux) recently to form developer’s life easy. Now administrators and developers can run Linux commands or can do programming from windows 10 itself.

let’s understand a touch on WSL1 and WSL2

What are WSL1 and WSL2

WSL (Windows Subsystem for Linux) was aimed to enable bash shell and core Linux commands/utilities for Developers and users. WSL2 (Windows subsystem for Linux version2) is an upgraded version of WSL1.

The main motto of introducing WSL2 was to increase the performance and to support full system call compatibility with a lighter VM. Installation of Docker, Editors, Core Linux utilities and Developer tools is now possible in WSL2.

A complete Linux kernel has been introduced by Microsoft and future upgrades will be in pipeline, the only major limitation of WSL is no GUI (although debatable), you have to deal with the command line.

Prerequisite to install WSL1 or WSL2

  • WSL1/WSL2 both are supported on Windows 10 and Windows server 2019 64 bit version only. WSL1 requires Windows 10 Build 16215 or later and WSL2 is only available for Windows10 Builds 19041 or higher.
  • Computer with Hyper-V or Virtualization support and enabled from Bios.
  • 64-bit Processor with Second Level Address Translation (SLAT) for WSL2. For WSL1, SLAT is not mandatory and it works fine without it.

Steps to Install Linux on Windows 10 using wsl1

  1. Check your windows version
  2. Enable Linux subsystem for Windows 10 feature and restart.
  3. Download, Extract and install Linux distribution
  4. Provide username and password for user
  5. Launch your Distribution.

I will show you all steps on Windows 10 latest update 2004 with Ubuntu 20.04 on the Command line and Ubuntu 18.04 on GUI

Step1 – Check your Windows version

Check your windows version using “Windows key + R” and type “Winver” in the run dialogue box.

Then open “system information” by typing “msinfo” in the search bar for hardware information (32 or 64bit). Look for the information “System type”, it must be 64 bit.

Step2 – Enable Linux subsystem to deploy Linux on Windows 10

–> Enable windows subsystem for Linux (WSL) using PowerShell

Open Powershell window “Run as administrator” from the search bar and type this command to enable the Linux subsystem for Windows 10 feature.

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

once the command is successful, restart your machine.

–> Enable windows subsystem for Linux using Graphical user interface (GUI)

  • Search for “Turn Windows Features on or off” in the windows search bar.
  • Open and scroll down – Select the “Windows subsystem for Linux” box and click OK. Restart your system.

Turn Windows Features on or off

Step3 – Download your favorite Linux Distro

Download your favorite Linux distro from the command line or Microsoft store, I will download Ubuntu 20.04 from the Power Shell command line. Replace “wslubuntu2004” with your “distro name” in the command.

Check out the Microsoft site to download manually.

Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile Ubuntu.appx -UseBasicParsing

Go to your Downloads directory using the cd command, Rename your distro file in the Powershell console.

For example

Ubuntu_2004.2020.424.0_x64.appx renamed to ubuntu.zip

Rename-Item .\Ubuntu_2004.2020.424.0_x64.appx .\Ubuntu.zip

Extract zip file from Powershell (PS) window.

Expand-Archive .\Ubuntu.zip .\Ubuntu

Now change to the Ubuntu or distro directory using the “cd” command and launch your “distro-name.exe“, “Ubuntu2004.exe” in my case.

Power Shell command line

Step4 – Provide your credentials

Once the installation will finish successfully, it will ask for a username and password for your Linux distro, so provide as per your preference.

enter-Username-password-wsl-windows10

Step5 – Validate your favorite Linux on windows 10

Search your “Distro name” in the Windows search bar and click “open“ and you will be in your favorite Linux prompt.

Steps to update WSL1 to WSL2 kernel in Windows 10

  1. Check your windows version
  2. Check for Second Level Address Translation (SLAT) using the systeminfo command.
  3. Enable Linux subsystem for Windows 10 feature and restart your machine
  4. Enable the “VM (Virtual machine) platform” component and restart your machine
  5. Install wsl2 Kernel
  6. Set WSL2 as your default version
  7. Install your favorite distro from the Microsoft Store app and Launch

Step6 – Check your windows version and architecture

Follow the instructions of “Step1” to check the windows version and 64bit architecture.

Step7 -Check for Second Level Address Translation (SLAT) for WSL2

The 64-bit processor with SLAT is the key requirement for WSL2. Run the systeminfo command and verify. If you don’t have SLAT support, then WSL2 will not work in your system.

Step8 – Enable Linux subsystem to install Linux on Windows 10

Enable Linux subsystem for Windows 10 feature and restart your machine as per Step2. 

Step9 – Enable virtualization

–> Enable virtual machine platform  feature using PowerShell

Enable the “VM (Virtual machine) platform” component in the PowerShell console and restart your machine.

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

Output

Deployment Image Servicing and Management tool
Version: 10.0.19041.329

Image Version: 10.0.19041.388

Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.

–> Enable virtual machine platform (Virtualization) feature using GUI

  • Search for “Turn Windows Features on or off” in the windows search bar.
  • Open and scroll down – Select the “Virtual machine platform” box and click OK. Now restart your machine.

Virtual machine platform

Step10 – Run Kernel installer

Install WSL2 Kernel as WSL2 requires an update to its kernel component. Download kernel by visiting “https://aka.ms/wsl2kernel” or click here.

Once the download completes, run the “.msi” installer and complete the wizard.

Step11 – Change WSL version

Set WSL2 as your default version and check your version. Update from WSL1 to WSL2 may take some time to complete.

wsl --set-default-version 2

Note

If wsl –set-default-version ends up as an invalid command, just enter wsl –help and provide command as listed in helpIf the –set-default-version is not listed, means it’s not supported by your windows10 build and try updating it to version 2004, Build 19041 or higher.

Step12 – Install Linux on Windows 10 using GUI

If you are working on the GUI (Graphical user interface), look for your favorite Linux distro from Microsoft Store, open “Microsoft store” from the search console

 

Click on Get to download and install your distro.

Click on Launch after download completes, it will ask for username and password for your Linux distro, so provide as per your preference.

Search your “Distro name” in the windows search bar and click “open“. I can see both Ubuntu 18.04 and Ubuntu 20.04 as installed using GUI and Command-line respectively.

Ubuntu 20.04 

Enjoy Linux on Windows 10.

let’s check the WSL version for Ubuntu 20.04 and Ubuntu 18.04. It must be WSL1 for ubuntu 20.04 and WSL2 for ubuntu 18.04 after the upgrade.

wsl --list --verbose

How to Uninstall Linux Distro (WSL) from windows 10

Step13 – Open PowerShell and remove the Distro package

Open PowerShell “Run as administrator” and run the below-mentioned command with your distro to list the package names.

Get-AppxPackage *distro-name*

For Example Ubuntu in my case

Get-AppxPackage *ubuntu*

Make a note of “your distro package name” as highlighted in the screenshot and Remove the package with the “Remove-AppxPackage” command.

Example

Get-AppxPackage "CanonicalGroupLimited.Ubuntu18.04onWindows" | Remove-AppxPackage

How to Disable WSL (Windows Subsystem for Linux) feature

Step14 – Disable Windows subsystem from PowerShell

Open Powershell, “Run as administrator” and execute the below-mentioned command, once you have completed distro package removal in step12.

Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Press “Y” to disable it.

It will restart your computer and you are done.

Step15 – Disable Windows subsystem for Linux from GUI.

  • Search for “Turn Windows Features on or off” in the windows search bar.
  • Open and scroll down – Remove the checkmark from the “Windows subsystem for Linux” box and click OK. Restart your system.

Windows subsystem for Linux

Note*

All the above-mentioned steps are applicable to “Install Linux on Windows 2019 using WSL” also.

Common errors and solutions regarding WSL

1# Fix for Error: 0x80040306

This error may occur during installation because Microsoft doesn’t support legacy consoles. So, to resolve this issue, you have to disable the legacy console.

Open Command prompt by typing “cmd.exe” -> Open properties by right-clicking title bar -> Uncheck use legacy console in cmd properties – then click ok.

2# Fix for Error: 0x80040154

This error may occur after a windows update, which sometimes results in disabling the windows subsystem for the Linux feature. So, to fix this issue, you just need to follow step 2 of this tutorial.

3# Fix for “The referenced assembly could not be found”

You may face this error while enabling WSL optional features. This may occur due to the bad installation. So to resolve this, you may try updating Windows to fix it or you may need to reinstall windows 10.

4# Fix for “Error: 0x1bc while setting WSL default version 2”

This error may occur while executing step 10 of this tutorial.  Follow step 9 of this tutorial (install kernel) to get this fix. If your CPU doesn’t support SLAT (second-level address translation). Then also, you won’t be able to upgrade to WSL2.

Summary Note

I have shown you, “How to put in Linux on Windows 10 with WSL1″, and the way to upgrade your WSL1 to WSL2 with the kernel upgrade and found out WSL2 is your default version.

If you liked this text, please share it on your social media and comment, if you’re facing any issues during installation.

Enjoy your favorite Linux on Windows, who knows in the future, Windows are going to be provided as a subsystem to Linux.

Signing off with this thought.

Leave a Comment