Table of Contents

安装WSL

记录一下WSL的安装步骤


问题

步骤

首先,在[Turn Windows Features on or off]中,开启[Windows Subsystem For Linux]和[Virtual Machine Platform]

以下命令都使用Power Shell,Windows版本太低可能不支持某些命令

查看可以安装的Linux版本:wsl --list --online

查看已经安装的版本:wsl -l -v
PS C:\Users\Admin> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-20.04    Stopped         2
  Ubuntu-22.04    Stopped         2
  Debian          Stopped         2

更改已经安装的WSL版本(1 or 2):wsl --set-version Ubuntu-20.04 2

安装特定的发行版:wsl --install --distribution <Distribution Name>

卸载某个发行版:wsl --unregister <Distribution Name>
PS C:\Users\Admin> wsl --unregister Ubuntu-22.04
Unregistering...

有问题看命令说明:wsl --help

或者可以直接到MS Store搜索WSL,找一个安装即可

安装完成后,第一次启动的时候,应该会要求设置用户名和密码

可能遇到的错误

Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x800701bc
Error: 0x800701bc WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80370102
Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS.
For information please visit https://aka.ms/enablevirtualization
Press any key to continue...