win10 install wsl2

I will follow Windows Subsystem for Linux Installation Guide for Windows 10 official docs

Open PowerShell as administrator

run

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


then check your system version, it must be updated to version 2004, Build 19041 or higher. If not, you can download a official tool windows update assistant

after updating to right version
run this code then restart your computer

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


after restarting your computer, please run on powershell

1
wsl --set-default-version 2


then you should update linux kernel, go to the official website, download it and run it to install.

Then, go to your win store and search ubuntu and choose a version download it, I choose 20.04

Then open it.

If you meet a error like me

Please run this command on powershell as the issues

1
2
3
4
sc query LxssManager
sc stop LxssManager
sc start LxssManager
sfc /scannow

then open ubuntu, and wait a moment.
set your name and password.
run this command to check your version

1
wsl --list --verbose

then set wsl2 to your default

1
wsl --set-version <distribution name> <versionNumber>

I set wsl --set-default-version 2

finally, you have already installed it.

have a good time!