适用于 Linux 的 Windows 子系统安装指南 (Windows 10)Windows Subsystem for Linux Installation Guide for Windows 10

安装适用于 Linux 的 Windows 子系统Install the Windows Subsystem for Linux

在安装适用于 WSL 的任何 Linux 分发版之前,必须确保已启用“适用于 Linux 的 Windows 子系统”可选功能:Before installing any Linux distros for WSL, you must ensure that the "Windows Subsystem for Linux" optional feature is enabled:

  1. 以管理员身份打开 PowerShell 并运行:Open PowerShell as Administrator and run:

    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    
  2. 出现提示时,重启计算机。Restart your computer when prompted.

安装所选的 Linux 分发版Install your Linux Distribution of Choice

若要下载并安装首选的分发版,可以选择三种做法:To download and install your preferred distro(s), you have three choices:

Windows 10 Fall Creators Update 和更高版本:从 Microsoft Store 安装Windows 10 Fall Creators Update and later: Install from the Microsoft Store

本部分适用于 Windows 内部版本 16215 或更高版本。This section is for Windows build 16215 or later. 遵循以下步骤检查内部版本Follow these steps to check your build.

  1. 打开 Microsoft Store,并选择你偏好的 Linux 分发版。Open the Microsoft Store and choose your favorite Linux distribution.

    Microsoft Store 中的 Linux 分发版视图

    单击以下链接会打开每个分发版的 Microsoft Store 页面:The following links will open the Microsoft store page for each distribution:

  2. 在分发版的页面中,选择“获取”From the distro's page, select "Get"

    Microsoft Store 中的 Linux 分发版视图

完成分发版的初始化Complete initialization of your distro

安装 Linux 分发版后,必须先初始化新的分发版实例一次才能使用该分发版。Now that your Linux distro is installed, you must initialize your new distro instance once, before it can be used.

疑难解答:Troubleshooting:

下面是相关的错误和建议的修复措施。Below are related errors and suggested fixes. 有关其他常见错误及其解决方法,请参阅 WSL 故障排除页Refer to the WSL troubleshooting page for other common errors and their solutions.

  • 安装失败并出现错误 0x80070003Installation failed with error 0x80070003

    • 适用于 Linux 的 Windows 子系统只能在系统驱动器(通常是 C: 驱动器)中运行。The Windows Subsystem for Linux only runs on your system drive (usually this is your C: drive). 请确保将分发版存储在系统驱动器上:Make sure that distros are stored on your system drive:
    • 打开“设置”->“存储”->“更多存储设置: 更改新内容的保存位置” 用于在 C: 驱动器中安装应用的系统设置屏幕截图Open Settings -> Storage -> More Storage Settings: Change where new content is saved Picture of system settings to install apps on C: drive
  • WslRegisterDistribution 失败并出现错误 0x8007019eWslRegisterDistribution failed with error 0x8007019e

  • 未启用“适用于 Linux 的 Windows 子系统”可选组件:The Windows Subsystem for Linux optional component is not enabled:

  • 打开“控制面板” -> “程序和功能” -> “打开或关闭 Windows 功能”-> 选中“适用于 Linux 的 Windows 子系统”,或使用本文开头所述的 PowerShell cmdlet。 Open Control Panel -> Programs and Features -> Turn Windows Feature on or off -> Check Windows Subsystem for Linux or using the PowerShell cmdlet mentioned at the begining of this article.