DEV Community

Cover image for Get Started with WSL2...
fharook shaik
fharook shaik

Posted on • Updated on

Get Started with WSL2...

This post will give a complete, easy way to enable Windows Subsystem for Linux(WSL) and upgrade to WSL2 in your Windows 10
system.

What's WSL?

WSL stands for Windows Subsystem for Linux is a project maintained by Microsoft that lets developers run supported GNU/Linux environment directly in your Windows Machine without the overhead of dual booting your PC or using a virtual Machine.

Check out more information about WSL here


WSL vs WSL2?

The major difference between WSL and WSL2 is full support system call compatibility and increased file system performance.
According to Microsoft, WSL2 uses an actual full linux kernel running on a managed VM (virtual Machine) with fast boot times.

Enough theory, I know you're excited to install WSL in your windows machine, but before that check that your PC meets the requirements.


Requirements:

  • At least 4GB of RAM(Recommended 8GB of RAM).
  • Definitely a Windows 10 Machine.

Check your Windows Version here.
Open Command Prompt and type winver , a pop-up will be displayed that shows enough information about the current Windows Version and Build.

Alt Text

  • For x64 machines: Microsoft Windows Version 1903 or higher, with Build 18362 or higher (Recommended).
  • For ARM64 machines: Microsoft Windows Version 2004 or higher, with Build 19041 or higher (Recommended).

Not sure of what type of machine you've, Open command prompt or powershell and type systeminfo. The respective will be shown under "System Type". As you can see, My system is of type x64-based PC.

Alt Text

  • Not Sure Which version of windows you're using. Check for Windows Updates from Settings or use the Windows Update Assistant.

Install the WSL2..

Let's get into the installation part.

  1. Open Start from search for Turn Windows features on or off. Alt Text
  2. Look for Virtual Machine Platform and Windows Subsystem for linux are checked. Alt Text
  3. Restart the system if needed.
  4. If you're intended to use just WSL, head over to Install the Linux Distribution. Follow further instructions to install or update to WSL2.
  5. In order to update to WSL2, you need to install the WSL2 kernel that can be find here.

for x64-based machine here
for ARM64 machine here


Set default version to WSL2

With the above step, you've successfully installed the WSL2. By default, your machine is set to WSL1. The following steps will let you to configure your machine to use WSL2

  • Open Powershell as adminstrator and enter the following command
wsl --set-default-version 2
Enter fullscreen mode Exit fullscreen mode
  • If you got something like this below, you're good to go with the next section. Alt Text
  • If you've encountered an error message such as WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel. You still need to install the kernel or try reinstalling the kernel after restarting the PC. (Still got errors comment down with the screenshot of error message. Happy to help)

Congratulations🎉!, with that steps done, you've successfully configured your machine to use WSL2 and lest with only one step i.e., Installing Linux distro.


Install a Linux Distro...

Microsoft store has a lots of linux distros that are readily available to download. I'll go with Ubuntu 20.04 LTS

  • Download the package from Microsoft Store

Alt Text

  • When it got installed, open the app and let the package set everything for you. Once it done, you'll be asked to enter new UNIX name and set a password.

Alt Text

  • Once it done, you'll be welcomed with the following details

Alt Text


Check whether your linux distro is running on WSL2.

These steps will let you know whether Ubuntu 20.4(in my case) is running on WSL2 or not.

  • Let the Ubuntu 20.04 app be running. Open cmd or powershell and enter the following command
wsl -l -v
Enter fullscreen mode Exit fullscreen mode
  • If you got something like this, Bravo🎉 your linux distro is running on WSL2.
    Alt Text

  • You're free to set your linux distro to either WSL or WSL2 by using the following command

wsl --set-version <distribution name> <versionNumber>
Enter fullscreen mode Exit fullscreen mode

<versionNumber> should be either 1 or 2


Congratulations!🎉, with that steps done, you've successfully configured and installed WSL2 on your windows machine.

Feel free to comment down any type of doubts/issues you've encountered. Would ❤️ to help.
Find this insightful
🤔 Give a ❤️ & share the knowledge with your friends.

NOTE: The above information shared with you is written by studying the original docs of WSL Installation guide for Windows 10 and some parts like commands are extracted from the docs. You can find the original docs here. This post is mainly intended for the enthusiasts who are willing to install WSL2 on their PC.

Top comments (0)