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

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

在安装任何 Linux 发行版 for WSL 之前, 必须确保已启用 "适用于 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:

  1. 从 Microsoft Store 下载并安装(见下文)Download and install from the Microsoft Store (see below)
  2. 从命令行/脚本下载并安装(阅读手动安装说明Download and install from the Command-Line/Script (read the manual installation instructions)
  3. 下载并手动解压缩,然后进行安装(适用于 Windows Server - 此处提供说明Download and manually unpack and install (for Windows Server - instructions here)

Windows 10 秋季创意者更新及更高版本:从 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. 在发行版的页面上, 选择 "Get"From the distro's page, select "Get"

    Microsoft 应用商店中的 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.