Руководство по установке подсистемы Windows для Linux в Windows 10 Windows Subsystem for Linux Installation Guide for Windows 10
Установка подсистемы Windows для Linux Install the Windows Subsystem for Linux
Перед установкой дистрибутивов Linux в Windows необходимо включить дополнительный компонент «Подсистема Windows для Linux». Before installing any Linux distributions on Windows, you must enable the «Windows Subsystem for Linux» optional feature.
Запустите PowerShell с правами администратора и выполните следующую команду. Open PowerShell as Administrator and run:
Чтобы установить только WSL 1, необходимо перезагрузить компьютер и перейти к пункту Install your Linux distribution of choice (Установить дистрибутив Linux), в противном случае дождитесь перезапуска и переходите к обновлению до WSL 2. To only install WSL 1, you should now restart your machine and move on to Install your Linux distribution of choice, otherwise wait to restart and move on to update to WSL 2. Узнайте больше о сравнении WSL 2 и WSL 1. Read more about Comparing WSL 2 and WSL 1.
Обновление до WSL 2 Update to WSL 2
Чтобы выполнить обновление до WSL 2, необходимо выполнить следующие условия: To update to WSL 2, you must meet the following criteria:
Использовать Windows 10 с обновлением до версии 1903 или выше, сборкой 18362 или выше для систем x64. Running Windows 10, updated to version 1903 or higher, Build 18362 or higher for x64 systems.
- Если вы работаете с Windows 10 версии 1903 или 1909, убедитесь, что используете номер сборки 1049 или выше. If you are on Windows 10 version 1903 or 1909 make sure your minor build number is 1049 or higher. Полные инструкции по устранению неполадок см. здесь. See full troubleshooting instructions here
Использовать Windows 10 с обновлением до версии 2004 или выше и сборкой 19041 или выше для систем ARM64. Running Windows 10, updated to version 2004 or higher, build 19041, for ARM64 systems.
Обратите внимание, что, если вы работаете с Windows 10 версии 1903 или 1909, необходимо убедиться, что используется надлежащее обновление. Инструкции можно найти здесь. Please note if you are on Windows 10 version 1903 or 1909 you will need to ensure that you have the proper backport, instructions can be found here.
Проверьте версию Windows, нажав Windows + R, введите winver, выберите ОК. Check your Windows version by selecting the Windows logo key + R, type winver, select OK. (Или введите команду ver в командной строке Windows). (Or enter the ver command in Windows Command Prompt). Обновите последнюю версию Windows, если сборка ниже 18361. Please update to the latest Windows version if your build is lower than 18361. Получите помощник по Центру обновления Windows. Get Windows Update Assistant.
Включение необязательного компонента «Virtual Machine Platform» (Платформа виртуальной машины) Enable the ‘Virtual Machine Platform’ optional component
Перед установкой WSL 2 необходимо включить необязательный компонент «Virtual Machine Platform» (Платформа виртуальных машин). Before installing WSL 2, you must enable the «Virtual Machine Platform» optional feature.
Запустите PowerShell с правами администратора и выполните следующую команду. Open PowerShell as Administrator and run:
Перезапустите компьютер, чтобы завершить установку и обновление WSL до WSL 2. Restart your machine to complete the WSL install and update to WSL 2.
Задать WSL 2 в качестве версии по умолчанию Set WSL 2 as your default version
Откройте PowerShell от имени администратора и выполните следующую команду, чтобы задать WSL 2 в качестве версии по умолчанию при установке нового дистрибутива Linux: Open PowerShell as Administrator and run this command to set WSL 2 as the default version when installing a new Linux distribution:
После выполнения этой команды может появиться следующее сообщение: WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel . You might see this message after running that command: WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel . Перейдите по ссылке (https://aka.ms/wsl2kernel) и установите MSI-файл с этой страницы документации, чтобы установить на компьютере ядро Linux для WSL 2. Please follow the link (https://aka.ms/wsl2kernel) and install the MSI from that page on our documentation to install a Linux kernel on your machine for WSL 2 to use. После установки ядра выполните команду еще раз. Она должна успешно завершиться без отображения сообщения. Once you have the kernel installed, please run the command again and it should complete successfully without showing the message.
Обновление с WSL 1 до WSL 2 может занять несколько минут в зависимости от размера целевого дистрибутива. The update from WSL 1 to WSL 2 may take several minutes to complete depending on the size of your targeted distribution. Если вы используете устаревшую установку WSL 1 из Юбилейного обновления Windows 10 или обновления Creators Update, может возникнуть ошибка обновления. If you are running an older (legacy) installation of WSL 1 from Windows 10 Anniversary Update or Creators Update, you may encounter an update error. Выполните эти инструкции, чтобы удалить устаревшие дистрибутивы. Follow these instructions to uninstall and remove any legacy distributions.
Если wsl —set-default-version выполняется как недопустимая команда, введите wsl —help . If wsl —set-default-version results as an invalid command, enter wsl —help . Если —set-default-version нет в списке, это указывает на отсутствие поддержки в ОС. Вам нужно выполнить обновление до версии 1903, сборки 18362 или выше. If the —set-default-version is not listed, it means that your OS doesn’t support it and you need to update to version 1903, Build 18362 or higher.
Установка дистрибутива Linux по выбору Install your Linux distribution of choice
Откройте Microsoft Store и выберите предпочтительный дистрибутив Linux. Open the Microsoft Store and select your favorite Linux distribution.
Ниже приведены ссылки на страницы Microsoft Store для каждого дистрибутива: The following links will open the Microsoft store page for each distribution:
На странице дистрибутива щелкните «Получить». From the distribution’s page, select «Get».
Настройка нового дистрибутива Set up a new distribution
При первом запуске недавно установленного дистрибутива Linux откроется окно консоли, и вам будет предложено подождать минуту или две, чтобы файлы распаковались и сохранились на компьютере. The first time you launch a newly installed Linux distribution, a console window will open and you’ll be asked to wait for a minute or two for files to de-compress and be stored on your PC. Все будущие запуски должны занимать меньше секунды. All future launches should take less than a second.
Установите вашу версию дистрибутива на WSL 1 или WSL 2 Set your distribution version to WSL 1 or WSL 2
Вы можете проверить версию WSL, назначенную каждому из установленных дистрибутивов Linux, открыв командную строку PowerShell и введя команду (доступна только в сборке Windows 18362 или выше): wsl -l -v . You can check the WSL version assigned to each of the Linux distributions you have installed by opening the PowerShell command line and entering the command (only available in Windows Build 18362 or higher): wsl -l -v
Чтобы настроить дистрибутив для одной из версий WSL, выполните: To set a distribution to be backed by either version of WSL please run:
Не забудьте заменить на фактическое имя дистрибутива и с номером «1» или «2». Make sure to replace with the actual name of your distribution and with the number ‘1’ or ‘2’. Вы можете всегда вернуться к WSL версии 1, выполнив эту команду и заменив «2» на «1». You can change back to WSL 1 at anytime by running the same command as above but replacing the ‘2’ with a ‘1’.
Кроме того, если вы хотите сделать WSL 2 архитектурой по умолчанию, выполните следующую команду: Additionally, if you want to make WSL 2 your default architecture you can do so with this command:
Будет установлена версия любого нового дистрибутива, установленного в WSL 2. This will set the version of any new distribution installed to WSL 2.
Устранение неполадок установки Troubleshooting installation
Ниже перечислены возможные ошибки и способы их устранения. Below are related errors and suggested fixes. Другие распространенные ошибки и способы их устранения приведены в разделе Устранение неполадок подсистемы Windows для Linux. Refer to the WSL troubleshooting page for other common errors and their solutions.
Сбой установки с ошибкой 0x80070003 Installation failed with error 0x80070003
- Подсистема Windows для Linux работает только на системном диске (обычно это диск C: ). The Windows Subsystem for Linux only runs on your system drive (usually this is your C: drive). Убедитесь, что дистрибутивы хранятся на системном диске. Make sure that distributions are stored on your system drive:
- Выберите Параметры ->Хранилище ->More Storage Settings: (Другие параметры хранилища:) Изменить место сохранения нового содержимого.
Open Settings ->Storage ->More Storage Settings: Change where new content is saved
Сбой WslRegisterDistribution с ошибкой 0x8007019e WslRegisterDistribution failed with error 0x8007019e
- Дополнительный компонент «Подсистема Windows для Linux» не включен. The Windows Subsystem for Linux optional component is not enabled:
- Выберите Панель управления ->Программы и компоненты ->Включение или отключение компонентов Windows и установите флажок Подсистема Windows для Linux или используйте командлет PowerShell, упомянутый в начале этой статьи. 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 beginning of this article.
Сбой установки с ошибкой 0x80070003 или ошибкой 0x80370102. Installation failed with error 0x80070003 or error 0x80370102
- Убедитесь, что в BIOS вашего компьютера включена виртуализация. Please make sure that virtualization is enabled inside of your computer’s BIOS. Расположение этого параметра зависит от компьютера, но обычно он находится в разделе настроек ЦП в BIOS. The instructions on how to do this will vary from computer to computer, and will most likely be under CPU related options.
При попытке обновления возникает ошибка Invalid command line option: wsl —set-version Ubuntu 2 . Error when trying to upgrade: Invalid command line option: wsl —set-version Ubuntu 2
- Убедитесь, что у вас включена подсистема Windows для Linux и используется сборка Windows 18362 или выше. Enure that you have the Windows Subsystem for Linux enabled, and that you’re using Windows Build version 18362 or higher. Чтобы включить WSL, выполните эту команду в командной строке PowerShell с правами администратора: Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux . To enable WSL run this command in a PowerShell prompt with admin privileges: Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux .
Запрошенную операцию не удалось выполнить из-за ограничения системы виртуального диска. Файлы виртуального жесткого диска должны быть распакованными, незашифрованными и не разреженными. The requested operation could not be completed due to a virtual disk system limitation. Virtual hard disk files must be uncompressed and unencrypted and must not be sparse.
- Снимите флажок Compress contents (Сжимать содержимое) (а также флажок Encrypt contents (Шифровать содержимое), если он установлен), открыв папку профиля для дистрибутива Linux. Deselect “Compress contents” (as well as “Encrypt contents” if that’s checked) by opening the profile folder for your Linux distribution. Он должен находиться в подпапке файловой системы Windows, для примера: USERPROFILE%\AppData\Local\Packages\CanonicalGroupLimited. . It should be located in a folder on your Windows file system, something like: USERPROFILE%\AppData\Local\Packages\CanonicalGroupLimited.
- В этом профиле дистрибутива Linux должна находиться папка LocalState. In this Linux distro profile, there should be a LocalState folder. Щелкните эту папку правой кнопкой мыши, чтобы отобразить меню параметров. Right-click this folder to display a menu of options. Выберите Properties (Свойства) > Advanced (Дополнительно) и убедитесь, что флажки Compress contents to save disk space (Сжимать содержимое для экономии места на диске) и Encrypt contents to secure data (Шифровать содержимое для защиты данных) не установлены. Select Properties > Advanced and then ensure that the “Compress contents to save disk space” and “Encrypt contents to secure data” checkboxes are unselected (not checked). Если вы увидите запрос на применение параметров к текущей папке или ко всем вложенным папкам и файлам, выберите вариант только для текущей папки, так как вы очищаете только флаг сжатия. If you are asked whether to apply this to just to the current folder or to all subfolders and files, select “just this folder” because you are only clearing the compress flag. После этого команда wsl —set-version будет работать правильно. After this, the wsl —set-version command should work.
В этом примере папка LocalState для дистрибутива Ubuntu 18.04 расположена по адресу C:\Users \AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc In my case, the LocalState folder for my Ubuntu 18.04 distribution was located at C:\Users \AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc
Чтобы получать обновленные сведения, проверьте ветку № 4103 в документации GitHub WSL, где отслеживается эта проблема. Check WSL Docs GitHub thread #4103 where this issue is being tracked for updated information.