适用于 Linux 的 Windows 子系统疑难解答
We have covered some common troubleshooting scenarios associated with WSL below, but please consider searching the issues filed in the WSL product repo on GitHub as well.
File an issue, bug report, feature request
The WSL product repo issues enables you to:
- Search existing issues to see if there are any associated with a problem that you are having. Note that in the search bar, you can remove "is:open" to include issues that have already been resolved in your search. Please consider commenting or giving a thumbs up to any open issues that you would like to express your interest in moving forward as a priority.
- File a new issue. If you have found a problem with WSL and there does not appear to be an existing issue, you can select the green New issue button and then choose WSL - Bug Report. You will need to include a title for the issue, your Windows build number (run
cmd.exe /c ver
to see your current build #), whether you're running WSL 1 or 2, your current Linux Kernel version # (runwsl.exe --status
orcat /proc/version
), the version # of your distribution (runlsb_release -r
), any other software versions involved, the repro steps, expected behavior, actual behavior, and diagnostic logs if available and appropriate. For more info, see contributing to WSL. - File a feature request by selecting the green New issue button and then select Feature request. You will need to address a few questions describing your request.
You can also:
- File a documentation issue using the WSL docs repo. To contribute to the WSL docs, see the Microsoft Docs contributor guide.
- File a Windows Terminal issue using the Windows Terminal product repo if your problem is related more to the Windows Terminal, Windows Console, or the command-line UI.
Installation issues
-
Installation failed with error 0x80070003
- 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: - On Windows 10 open Settings -> System -> Storage -> More Storage Settings: Change where new content is saved
- On Windows 11 open Settings -> System -> Storage -> Advanced storage settings -> Where new content is saved
- The Windows Subsystem for Linux only runs on your system drive (usually this is your
-
WslRegisterDistribution failed with error 0x8007019e
- The Windows Subsystem for Linux optional component is not enabled:
- 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.
-
Installation failed with error 0x80070003 or error 0x80370102
- Please make sure that virtualization is enabled inside of your computer's BIOS. The instructions on how to do this will vary from computer to computer, and will most likely be under CPU related options.
- WSL2 requires that your CPU supports the Second Level Address Translation (SLAT) feature, which was introduced in Intel Nehalem processors (Intel Core 1st Generation) and AMD Opteron. Older CPUs (such as the Intel Core 2 Duo) will not be able to run WSL2, even if the Virtual Machine Platform is successfully installed.
-
Error when trying to upgrade:
Invalid command line option: wsl --set-version Ubuntu 2
- Ensure that you have the Windows Subsystem for Linux enabled, and that you're using Windows Build version 18362 or later. To enable WSL run this command in a PowerShell prompt with admin privileges:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
.
- Ensure that you have the Windows Subsystem for Linux enabled, and that you're using Windows Build version 18362 or later. To enable WSL run this command in a PowerShell prompt with admin privileges:
-
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.
- Deselect "Compress contents" (as well as "Encrypt contents" if that’s checked) by opening the profile folder for your Linux distribution. It should be located in a folder on your Windows file system, something like:
%USERPROFILE%\AppData\Local\Packages\CanonicalGroupLimited...
- In this Linux distro profile, there should be a LocalState folder. Right-click this folder to display a menu of options. 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. After this, the
wsl --set-version
command should work.
- Deselect "Compress contents" (as well as "Encrypt contents" if that’s checked) by opening the profile folder for your Linux distribution. It should be located in a folder on your Windows file system, something like:
[!NOTE] In my case, the LocalState folder for my Ubuntu 18.04 distribution was located at C:\Users<my-user-name>\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc
Check WSL Docs GitHub thread #4103 where this issue is being tracked for updated information.
-
The term 'wsl' is not recognized as the name of a cmdlet, function, script file, or operable program.
- Ensure that the Windows Subsystem for Linux Optional Component is installed. Additionally, if you are using an ARM64 device and running this command from PowerShell, you will receive this error. Instead run
wsl.exe
from PowerShell Core, or Command Prompt.
- Ensure that the Windows Subsystem for Linux Optional Component is installed. Additionally, if you are using an ARM64 device and running this command from PowerShell, you will receive this error. Instead run
-
Error: Windows Subsystem for Linux has no installed distributions.
- If you receive this error after you have already installed WSL distributions:
- Run the distribution at least once before invoking it from the command line.
- Check whether you may be running separate user accounts. Running your primary user account with elevated permissions (in admin mode) should not result in this error, but you should ensure that you aren't accidentally running the built-in Administrator account that comes with Windows. This is a separate user account and will not show any installed WSL distributions by design. For more info, see Enable and Disable the Built-in Administrator Account.
- The WSL executable is only installed to the native system directory. When you’re running a 32-bit process on 64-bit Windows (or on ARM64, any non-native combination), the hosted non-native process actually sees a different System32 folder. (The one a 32-bit process sees on x64 Windows is stored on disk at \Windows\SysWOW64.) You can access the "native" system32 from a hosted process by looking in the virtual folder:
\Windows\sysnative
. It won’t actually be present on disk, mind you, but the filesystem path resolver will find it.
-
Error: This update only applies to machines with the Windows Subsystem for Linux.
-
To install the Linux kernel update MSI package, WSL is required and should be enabled first. If it fails, it you will see the message:
This update only applies to machines with the Windows Subsystem for Linux
. -
There are three possible reason you see this message:
-
You are still in old version of Windows which doesn't support WSL 2. See step #2 for version requirements and links to update.
-
WSL is not enabled. You will need to return to step #1 and ensure that the optional WSL feature is enabled on your machine.
-
After you enabled WSL, a reboot is required for it to take effect, reboot your machine and try again.
-
-
Error: WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel .
- If the Linux kernel package is missing in the %SystemRoot%\system32\lxss\tools folder, you will encounter this error. Resolve it by installing the Linux kernel update MSI package in step #4 of these installation instructions. You may need to uninstall the MSI from 'Add or Remove Programs', and install it again.
Common issues
I'm on Windows 10 version 1903 and I still do not see options for WSL 2
This is likely because your machine has not yet taken the backport for WSL 2. The simplest way to resolve this is by going to Windows Settings and clicking 'Check for Updates' to install the latest updates on your system. See the full instructions on taking the backport.
If you hit 'Check for Updates' and still do not receive the update you can install KB KB4566116 manually.
Error: 0x1bc when wsl --set-default-version 2
This may happen when 'Display Language' or 'System Locale' setting is not English.
wsl --set-default-version 2
Error: 0x1bc
For information on key differences with WSL 2 please visit https://aka.ms/wsl2