WSL 2 on Windows Part 1 - Installation and Activation
I’m used to using Linux or Mac terminals for work.
I took some time to set up the WSL environment on my home PC to easily switch work environments.
Differences between WSL 2 and WSL 1
WSL 2 is based on Hyper-V and runs a full Linux kernel in a virtual machine.
WSL 1 is a simulation of Linux functionalities on the Windows system.
Therefore, WSL 2 supports more native Linux features and system calls than WSL 1.
If you need to use low-level Linux applications,
WSL 2 offers better support than WSL 1.
Generally, WSL 2 also has better performance for starting processes,
except when reading files from the host system.
However, because WSL 2 runs a Linux kernel in a VM,
its integration with Windows as the host is relatively poorer than WSL 1.
Processes within WSL 2 cannot be managed by Windows Task Manager,
and there’s an additional layer in the network connection between Windows and WSL 2.
Due to WSL 2’s use of Hyper-V,
I’ve heard reports of incompatibility issues with VMWare.
I don’t use VMWare, so I don’t know if this issue is real,
but I haven’t encountered any problems when using Docker.
Microsoft Doc lists a detailed comparison of WSL 1 and WSL 2.
Requirements
Windows version must be Windows 10. If your version is lower, please use Windows Update:
- For X64 systems: Version 1903 or higher, with Build 18362 or higher.
- For ARM64 systems: Version 2004 or higher, with Build 19041 or higher.
The machine must have virtualization features enabled.
This can usually be found in the motherboard’s BIOS settings.
Look for settings related to CPU configuration, such as Intel Virtualization,
and enable it.
Installing and Activating WSL 2
Open PowerShell with administrator privileges.
- Enable Windows Subsystem for Linux: Run
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart- Enable Virtual Machine Platform optional feature: Run
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart- Restart your computer.
- Download and install the WSL 2 Linux kernel update package.
- Set WSL 2 as the default version:
wsl --set-default-version 2- Go to the Microsoft Store,
find the Linux distribution you want to install,
and install it, setting up your account and password. - You can check the WSL version of the installed Linux distribution in PowerShell:
wsl -l -vYou can also change the WSL version of a Linux distribution:
wsl --set-version <distribution name> <versionNumber>Reference
Microsoft WSL 2 Installation Guide
Microsoft DOC: Compare WSL 1 and WSL 2