如何在Windows WSL上安装Debian

要在Windows 10上安装WSL 2,必须满足这两个要求:

  • Windows 10 5月20日(2004),Windows 2019年5月10日(1903),或者2019年11月10日(1909)或者更高版本的Windows 10
  • 支持Hyper-V虚拟化的计算机

启用虚拟机平台

WSL 2要求启用Windows 10虚拟机平台。

要在Windows中启用VM Platform功能,在PowerShell管理员控制台中运行下面命令:

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

如果我们使用的是Windows 10版本低于2004,请使用以下命令:

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart

完成上面运行命令后,重新启动计算机以获取要应用的所有配置更改。
如果不重新启动,则可能无法识别以下命令。

重启后,在PowerShell中运行以下命令,将WSL 2配置为WSL的默认版本。

wsl --set-default-version 2

如果我们收到了未安装Linux内核的错误,请从下面的链接中获取它并在Windows中运行它,然后再次尝试上面的命令。

https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

在Windows中启用WSL

单击开始,找到powershell

右键单击Windows PowerShell应用程序,然后选择以管理员身份运行。

当控制台打开时,请运行以下命令:

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

安装后,将显示类似下面的成功消息:

Deployment Image Servicing and Management tool
Version: 10.0.19041.844
Image Version: 10.0.19042.844
Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.

在Windows 10中安装Debian

Debian在Windows上允许我们使用Debian终端并运行Debian命令行实用程序,包括Bash,SSH,Git,APT等等。

从Windows商店的Debian副本下载并安装:

https://www.microsoft.com/en-us/p/debian/9msvkqc78pk6?activetab=pivot:overviewtab

单击“获取”按钮并安装。
安装Debian后,我们将希望选项从Windows WSL环境启动Debian。

下载并安装后,我们将获得一个启动按钮。

启动Debian后,它应该安装并提示创建帐户。

Installing, this may take a few minutes. 
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: jack
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
jack@DESKTOP-M1235UB:~$
日期:2020-07-07 20:57:01 来源:oir作者:oir