Install WSL2 on Windows 11 and Windows 10 with Easy Steps

Posted on

Install WSL2 on Windows 11 and Windows 10 with Easy Steps

Install WSL2 on Windows 11 and Windows 10 with Easy Steps

This guide will walk you through the process of install WSL2 on Windows 11 and Windows 10. The Windows Subsystem for Linux (WSL) is a powerful tool from Microsoft that allows you to run a Linux environment directly on Windows. It offers a seamless experience, providing a complete Linux shell that can interact with your existing Windows file system.

WSL2, released in early 2020, is an evolution of the original Windows Subsystem for Linux (WSL1). While WSL1 used a compatibility layer to translate code execution between Windows and Linux, WSL2 leverages actual virtualization of a Linux operating system.

WSL2 offers significant advantages. It provides a complete Linux kernel and requires less memory compared to WSL1. Let’s dive into the steps required to install WSL2 on Windows 11 and Windows 10. You can easily install WSL2 on Windows 11 and Windows 10 by following the easy steps we provide.

To get started, you need a Windows 10 or Windows 11 PC. For the best experience, ensure you’re running Windows 10 version 21H1, 21H2, or 22H2, or Windows 11 21H2 with all the latest updates applied.

Install WSL2 on Windows

Install WSL2 on Windows

The simplest way to install WSL2 on Windows 11 and Windows 10 is to use the command line. Open PowerShell or Command Prompt as an administrator. Then, run the following command:

wsl --install

Note: By default, this command enables all necessary system features and installs Ubuntu. If you don’t want a distribution installed during setup, you can use the --no-distribution option:

When the installation is complete, restart your Windows system.

Install WSL2 with a Specific Distro on Windows

If you prefer a different Linux distribution, WSL2 provides an option to choose one during installation. Here’s how:

First, list the available distributions:

wsl --list --online

This command displays a list of available WSL distros.

Then, install your preferred distro using the following command, replacing <DISTRO-NAME> with the actual name of the distribution:

wsl --install -d <DISTRO-NAME>

For example, to install Debian, you would use:

wsl --install -d Debian

After installation, restart your computer.

Update WSL2 kernel

Keep your WSL2 kernel up-to-date for the latest features and security improvements. Run the following command:

wsl --update

This command checks for and installs any available updates.

Set WSL2 as Default

WSL2 doesn’t replace WSL1. Both can coexist. You can even specify which version each Linux distribution uses. To set WSL2 as the default for all new installations, use this command:

wsl --set-default-version 2

You can check the WSL version being used by each installed distribution with the following command:

wsl --list --verbose

For more detailed information, refer to the official WSL Documentation.

Conclusion

You have now successfully learned how to install WSL2 on Windows 11 and Windows 10.

You might also find these articles helpful:

Alternative Installation Methods

While the wsl --install command offers a streamlined approach, there are alternative methods to install WSL2 on Windows 11 and Windows 10. These methods provide more granular control over the installation process and can be helpful in specific scenarios, such as when troubleshooting issues or customizing the installation.

Method 1: Manual Installation via PowerShell

This method involves manually enabling the necessary Windows features and then installing a Linux distribution from the Microsoft Store.

Step 1: Enable the Windows Subsystem for Linux feature:

Open PowerShell as an administrator and run the following command:

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

Step 2: Enable the Virtual Machine Platform feature:

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

Step 3: Restart your computer:

This is crucial for the features to be properly enabled.

Step 4: Download and install the Linux kernel update package:

Visit https://aka.ms/wsl2kernel and download the latest WSL2 Linux kernel update package. Run the downloaded file to install the kernel.

Step 5: Set WSL 2 as the default version:

wsl --set-default-version 2

Step 6: Install a Linux distribution from the Microsoft Store:

Open the Microsoft Store app and search for your preferred Linux distribution (e.g., Ubuntu, Debian, Kali Linux). Click "Get" to download and install the distribution.

Step 7: Launch the installed distribution:

After installation, launch the distribution from the Start menu. It will prompt you to create a user account and password.

This manual method gives you more control over each step. For example, if you encounter issues enabling the Virtual Machine Platform, you can investigate specific virtualization settings in your BIOS/UEFI firmware.

Method 2: Using DISM (Deployment Image Servicing and Management)

DISM is a command-line tool used for servicing Windows images. It can be used to enable the necessary Windows features for WSL2. This method is particularly useful in automated deployment scenarios or when PowerShell is not readily available.

Step 1: Open Command Prompt as an administrator.

Step 2: Enable the Windows Subsystem for Linux feature using DISM:

DISM /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Step 3: Enable the Virtual Machine Platform feature using DISM:

DISM /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Step 4: Restart your computer.

shutdown /r /t 0

Step 5: Download and install the Linux kernel update package (same as Step 4 in Method 1).

Step 6: Set WSL 2 as the default version (same as Step 5 in Method 1).

Step 7: Install a Linux distribution from the Microsoft Store (same as Step 6 in Method 1).

Step 8: Launch the installed distribution (same as Step 7 in Method 1).

DISM provides a more direct way to enable features at a system level. It’s especially valuable for scripting and automated deployments. For example, you could create a batch script to automatically enable WSL2 features as part of a larger system configuration process. The /norestart parameter allows you to defer the restart until all necessary features have been enabled, minimizing the number of reboots required.

Leave a Reply

Your email address will not be published. Required fields are marked *