像所有软件一样,Windows 子系统 (WSL2)也有很多问题。在本指南中,我们将对Linux错误消息和代码的 Windows 子系统进行故障排除。(Windows Subsystem for Linux)
(Fix Windows Subsystem)修复适用于Linux 错误(Linux Errors)、问题(Problems)和问题的(Issues)Windows 子系统
这些是我们将针对Linux 错误消息(Linux Error Messages)和代码的(Codes)Windows 子系统(Windows Subsystem)进行故障排除的消息。
- 看不到 WSL 2 的选项
- 错误:0x1bc
- 错误:安装时出现 0x80040306
- 无法从 Windows访问WSL文件(WSL)
- 无法启动WSL 2分发,只能在输出中看到“ WSL 2 ”
- 找不到命令
- 错误:0x80370102 无法启动虚拟机,因为未安装必需的功能
- 错误: Windows(Windows)更新后出现 0x80040154
- WSL 停止(WSL Stops)工作并出现 错误 0x80070003(Error 0x80070003)
- 在 WSL 中显示语言更改
- (Installation)Windows系统还原后的安装问题
- WSL 中无法访问 Internet
- 使用 Ping 时权限被拒绝
- 安装WSL 2(WSL 2)后无法启动
- 无法在分发服务器中运行Windows 命令(Windows Commands)
- ICS 已禁用
- Bash 挂了
- OpenSSH 服务器连接问题
- 找不到引用的程序集
- 更正(Correct)(与SSH相关的)权限错误
让我们详细谈谈它们。
1] 看不到 WSL 2 的选项
许多Windows用户抱怨说,即使他们的版本号为 1903,他们也看不到WSL 2的选项。当您的计算机尚未采用WSL 2的反向端口时,就会发生这种情况。
要解决此问题,您只需要检查更新( check for updates),就可以了。
2]错误:0x1bc
当“显示语言” (“Display Language” )或 “系统区域设置” (“System Locale” )未设置为 英语(English.)时,您可能会看到以下错误。
wsl --set-default-version 2
Error: 0x1bc
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
要修复错误,您需要检查您的计算机上是否安装了内核。(Kernel)为此,请使用以下命令。
dir %SystemRoot%\system32\lxss\tools\kernel
如果您没有Kernel,请从aka.ms下载。确保以管理员身份下载并在您的机器上安装内核(Kernel)以修复错误。
3]错误:安装时出现0x80040306
如果您在安装时看到错误:0x80040306。要解决此问题,您需要禁用 旧版控制台。 (Legacy Console. )为此,请按照给定的步骤操作。
- 从开始菜单(Start Menu.)以管理员身份 打开 命令提示符 。(Command Prompt )
- 右键单击(Right-click)cmd 徽标并选择属性。(Properties.)
- 现在,取消选中“使用旧控制台” (Use legacy console” ),然后单击确定。
最后,检查它是否解决了问题。
4] 无法从 Windows访问WSL文件(WSL)
如果您无法在Windows 上通过\\wsl$ 访问Windows Subsystem(Windows Subsystem) for Linux,这可能意味着 9P 协议文件服务器无法启动。
最简单的解决方法是更新您的计算机并启用“Windows Update 上的 Microsoft 产品更新”。 (“updates for Microsoft products on Windows Update”. )为此,您可以按照给定的步骤操作。
- 通过 Win + I.启动 设置 。(Settings )
- 单击 Update & Security > Advanced options.
- 使用切换禁用“在更新 Windows 时接收其他 Microsoft 产品的更新(Receive updates for other Microsoft products when you update Windows)”。
这将为您解决问题。
5] 无法启动WSL 2分发,只能在输出中看到“ WSL 2 ”
如果您的显示语言未设置为英语,则此错误是不可避免的。尝试启动WSL 2时,您将看到以下输出。
C:\Users\me>wsl
WSL 2
要修复该错误,您需要手动下载并安装内核。(Kernel)aka.ms/wsl2kernel下载该文件。安装内核(Kernel)以轻松修复错误。
6]找不到命令
这是他们在Linux中运行(Linux)Windows的 .exe 文件时看到的常见错误之一。尝试执行相同操作时,您可能会看到以下错误。
$ notepad.exe
-bash: notepad.exe: command not found
当 $PATH 找不到.exe文件时会发生这种情况。此错误的最佳解决方案是在终端(Terminal)中运行以下命令。
export PATH=$PATH:/usr/sbin
执行此操作并检查它是否修复了错误。
7]错误:0x80370102无法启动虚拟机,因为未安装必需的功能
许多人在尝试安装Linux分发器时遇到此错误。与以前的错误不同,此错误有多个解决方案。因此,系好安全带并阅读所有解决方案。
这些是您可以做的事情来修复错误:0x80370102, The virtual machine could not be started because an required feature is not installed。
- 启用 Hyper-V
- 启用硬件虚拟化
- 启用嵌套虚拟化
让我们详细谈谈它们。
启用 Hyper-V
如果没有Hyper-V,您将无法创建虚拟环境(Environment)。因此,请在以下步骤的帮助下启用它。
- 从 开始菜单(Start Menu.)打开 控制面板 。(Control Panel )
- 单击 Programs and Features > Turn Windows features on or off
- 向下滚动(Scroll)以找到Hyper-V,检查它,然后单击确定。
启用Hyper-V后,检查问题是否已修复。
启用硬件虚拟化
(Hardware Virtualization)尝试运行虚拟机时必须进行(Virtual Machine)硬件虚拟化。因此,如果您遇到错误:0x80370102,请尝试从 BIOS启用硬件虚拟化(enable Hardware Virtualization)以解决问题。
启用嵌套虚拟化
嵌套虚拟化(Virtualization)允许您在 VM 内运行Hypervisor。因此,如果您仍然面临错误,请尝试启用嵌套虚拟化(Virtualization)。为此,您需要以管理员身份运行PowerShell 并运行以下命令。(PowerShell )
Set-VMProcessor -VMName <VMName> -ExposeVirtualizationExtensions $true
让这个命令运行并检查它是否解决了问题。
8]错误: Windows(Windows)更新后0x80040154
如果由于Windows 更新(Windows Update)而禁用了适用于Linux的(Linux)Windows 子系统(Windows Subsystem),您可能会看到此错误。因此,要解决此问题,我们需要启用此选项。为此,请按照给定的步骤操作。
- 从 开始菜单(Start Menu.)启动 控制 。(Control )
- 单击 Programs and Features > Turn Windows features on or off
- 向下滚动以找到适用于 Linux 的 Windows 子系统(Windows Subsystem for Linux),选中它,然后单击确定。
最后,重新启动计算机并检查问题是否仍然存在。
9] WSL 停止(WSL Stops)工作并出现 错误 0x80070003(Error 0x80070003)
如果 WSL 停止并出现此错误代码 0x80070003(error code 0x80070003),请使用本指南解决。
10]在WSL中更改显示语言(Display)
WSL会自动更改Ubuntu语言环境,使其与您的Windows计算机的语言相匹配。如果您不喜欢这个动作,请使用以下命令根据您的需要设置显示语言。
注意:以下命令会将语言更改为 en-US。
sudo update-locale LANG=en_US.UTF8
这样做并检查它是否解决了问题。
11] Windows系统还原后的安装(Installation)问题
如果您在Windows系统还原后遇到安装(Installation)问题,请尝试删除Windows Subsystem for Linux文件夹。以下是它的路径。
%windir%\System32\Tasks\Microsoft\Windows\Windows Subsystem for Linux
重新启动计算机,重新安装Bash并检查它是否解决了问题。
12] WSL 中无法访问互联网
许多用户报告说他们无法在WSL中访问(WSL)Internet。但是,解决方案可能比您想象的要容易。发生这种情况是因为您可能拥有任何第三方防病毒软件。由于防火墙阻止了互联网(Internet)。因此,要解决此问题,请删除防病毒软件,一切顺利。
13]使用Ping时权限被拒绝(Permission)
如果您无法在WSL中 Ping,则这意味着您没有管理权限。因此,您需要在具有管理权限的命令行解释器上运行具有管理权限的Ubuntu和Linux或Bash.exe。
希望这可以轻松解决问题。
14] 安装WSL 2(WSL 2)后无法启动
安装WSL 2(WSL 2)后无法启动的原因 仍然令人费解,但Microsoft正在尝试进行更新以全面诊断问题。但是,您可以做两件事,看看它是否能解决问题。
- 使用系统还原点修复错误。
- 更新您的图形驱动程序(Update your Graphics Driver),看看它是否能解决问题。
15] 无法在分发服务器中运行Windows 命令(Windows Commands)
Windows 应用商店(Windows Store)中的一些分销商并未完全优化以运行所有Windows 命令(Windows Commands)。您可能会收到以下任何错误。
-bash: powershell.exe: command not found
powershell.exe /c start
要修复此错误,请运行以下命令。
echo $PATH
现在,检查输出是否包含“/mnt/c/Windows/system32”,如果您遇到错误,那么很可能路径不存在。
现在,通过以下方式检查您的个人资料设置
cat /etc/profile
现在,检查路径(Path)分配是否以“#”开头,如果是,请注释掉该块。另外,检查wsl.conf是否存在并确保它没有appendWindowsPath=false
. 如果是这样,请将其注释掉。
完成此操作后,您需要重新启动分发。您可以使用以下命令来执行此操作。
wsl -t <name of the distributor>
或者
wsl --shutdown
希望这个问题能得到解决。
16] ICS被禁用
没有ICS 或 Internet 连接共享(ICS or Internet Connection Sharing),WSL 就无法运行。主机网络服务 (HNS) (Host Network Service (HNS) )使用 ICS为WSL 2构建基本虚拟网络,以创建NAT、DNS、DHCP和主机连接共享。
要修复错误,我们需要启用ICS。因此,请按照给定的步骤启用ICS。
- 从 开始菜单(Start Menu.)启动 服务 。(Services )
- 双击Internet 连接共享 (ICS), (Internet Connection Sharing (ICS), )如果它已停止,请单击 开始 。(Start )
- 最后,单击 Apply > Ok.
您还应该编辑一些策略。因此,启动 组策略编辑器 (Group Policy Editor )并导航到以下位置。
Computer Configuration > Administrative Templates > Network > Network Connections
并禁用以下策略。
- 禁止(Prohibit)在您的DNS域网络上安装和配置网桥(Network Bridge)
- 禁止在您的DNS域网络上使用Internet 连接防火墙(Internet Connection Firewall)
- 禁止在您的DNS域网络上使用Internet 连接(Internet Connection)共享
- 设置网络位置时要求(Require)域用户提升权限
17]重击挂起
当Bash挂起或死锁并停止响应您的输入时,您可以重新启动计算机,因为这将修复错误或报告内存转储。后者可能会导致系统崩溃,因此,请在报告之前保存您的工作。
18] OpenSSH-Server 连接问题
如果您看到任何 OpenSSF-Server 连接问题,您需要做的第一件事是检查OpenSSH-Server是否正在运行。您可以使用以下命令来执行此操作。
sudo service ssh status
如果它没有运行,请使用以下命令启动服务。
sudo service ssh start
如果它正在运行,您应该使用以下命令重新启动服务并检查它是否解决了问题。
sudo service ssh restart
如果无法解决问题,请尝试在调试模式下启动SSHD 。在此之前,使用以下命令停止SSH服务。
sudo service ssh stop
现在,使用以下命令以调试模式启动SSHD。
sudo /usr/sbin/sshd -d
希望这可以修复错误。
19]找不到引用的程序集
许多用户在尝试启用WSL附加功能时遇到“找不到引用的程序集” 。(“The referenced assembly could not be found”)如果您是其中之一,请尝试从控制面板启用(Control Panel)适用于 Linux 的 Windows 子系统 (Windows Subsystem for Linux )并更新您的计算机。希望(Hopefully)这将修复错误。
20]纠正(Correct)(SSH相关)权限错误
如果您看到以下错误,请在此部分讨论解决方案。
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for '/home/artur/.ssh/private-key.pem' are too open.
要解决此问题,Microsoft建议您转到/etc/wsl.conf 文件并附加以下内容:
[automount]
enabled = true
options = metadata,uid=1000,gid=1000,umask=0022
这将修复错误。在执行此操作之前,请确保您有足够的权限。
这些是一些适用于Linux 错误消息(Linux Error Messages)和代码的(Codes)Windows 子系统(Windows Subsystem)及其故障排除技巧。我们希望它们能帮助您解决 WSL 错误、问题(Problems)和问题(Issues)。
Fix Windows Subsystem for Linux Errors, Problems and Issues
Lіke all software, the Windows Subsystem (WSL2) too has its fair shares of issues. In this guide, we are going tо troubleshoot Windows Subsystem for Linux Error Messages and Codes.
Fix Windows Subsystem for Linux Errors, Problems & Issues
These are messages for which we are going to troubleshoot Windows Subsystem for Linux Error Messages and Codes.
- Do not see options for WSL 2
- Error: 0x1bc
- Error: 0x80040306 on Installation
- Cannot access WSL files from Windows
- Can’t start WSL 2 distribution and only see ‘WSL 2’ in output
- Command Not Found
- Error: 0x80370102 The virtual machine could not be started because a required feature is not installed
- Error: 0x80040154 after Windows update
- WSL Stops working with Error 0x80070003
- Display language changing in WSL
- Installation issues after Windows system restore
- No internet access in WSL
- Permission Denied when using Ping
- Unable to boot after installing WSL 2
- Not able to run Windows Commands inside a distributor
- ICS is disabled
- Bash is hung
- OpenSSH-Server connection issues
- The referenced assembly could not be found
- Correct (SSH related) permission errors
Let us talk about them in detail.
1] Do not see options for WSL 2
Many Windows users have complained that even though they are at built no 1903, they are unable to see options for WSL 2. This happens when your computer machine has not yet taken the backport for WSL 2.
To fix this, you just need to check for updates, and you will be good to go.
2] Error: 0x1bc
You may see the following error when the “Display Language” or “System Locale” is not set to English.
wsl --set-default-version 2
Error: 0x1bc
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
To fix the error, you need to check if the Kernel is installed on your computer. To do that, use the following command.
dir %SystemRoot%\system32\lxss\tools\kernel
If you don’t have Kernel, download it from aka.ms. Make sure to download it as an administrator and install the Kernel on your machine to fix the error.
3] Error: 0x80040306 on Installation
If you are seeing Error: 0x80040306 on Installation. To fix this you need to disable Legacy Console. To do that, follow the given steps.
- Open Command Prompt as an administrator from the Start Menu.
- Right-click on the cmd logo and select Properties.
- Now, uncheck “Use legacy console” and click Ok.
Finally, check if it fixes the issue.
4] Cannot access WSL files from Windows
If you are unable to access Windows Subsystem for Linux by \\wsl$ on Windows, this could be mean that the 9P protocol file server fails to start.
The easiest fix is to update your computer and enable “updates for Microsoft products on Windows Update”. To do that, you can follow the given steps.
- Launch Settings by Win + I.
- Click Update & Security > Advanced options.
- Use the toggle to disable “Receive updates for other Microsoft products when you update Windows“.
This will fix the issue for you.
5] Can’t start WSL 2 distribution and only see ‘WSL 2’ in output
This error is inevitable if your display language is not set to English. You will see the following output when trying to start WSL 2.
C:\Users\me>wsl
WSL 2
To fix the error, you need to download and install the Kernel manually. You can download the file from aka.ms/wsl2kernel. Install the Kernel to fix the error easily.
6] Command Not Found
This is one of the common errors one sees when they run a .exe file of Windows in Linux. You may see the following error when trying to do the same.
$ notepad.exe
-bash: notepad.exe: command not found
This happens when the $PATH fails to find the .exe file. The best solution for this error is to run the following command in the Terminal.
export PATH=$PATH:/usr/sbin
Do this and check if it fixes the error.
7] Error: 0x80370102 The virtual machine could not be started because a required feature is not installed
Many have experienced this error when trying to install a Linux distributor. Unlike previous errors, this error has more than one solution. So, buckle up and read all the solutions.
These are the things you can do to fix Error: 0x80370102, The virtual machine could not be started because a required feature is not installed.
- Enable Hyper-V
- Enable Hardware Virtualization
- Enable Nested Virtualization
Let us talk about them in detail.
Enable Hyper-V
Without Hyper-V, you won’t be able to create a Virtual Environment. So, enable it with the help of the following steps.
- Open Control Panel from the Start Menu.
- Click Programs and Features > Turn Windows features on or off
- Scroll down to find Hyper-V, check it, and click Ok.
After enabling Hyper-V check if the issue is fixed.
Enable Hardware Virtualization
Hardware Virtualization is a must when trying to run Virtual Machine. So, if you facing the Error: 0x80370102, try to enable Hardware Virtualization from the BIOS to fix the issue.
Enable Nested Virtualization
Nested Virtualization allows you to run Hypervisor inside a VM. So, if you are still facing the error, try enabling Nested Virtualization. To do that, you need to run PowerShell as an administrator and run the following command.
Set-VMProcessor -VMName <VMName> -ExposeVirtualizationExtensions $true
Let this command run and check if it fixes the issue.
8] Error: 0x80040154 after Windows update
You may see this error if Windows Subsystem for Linux is disabled because of a Windows Update. So, to fix the issue, we need to enable this option. To do that, follow the given steps.
- Launch Control from the Start Menu.
- Click Programs and Features > Turn Windows features on or off
- Scroll down to find Windows Subsystem for Linux, check it, and click Ok.
Finally, restart your computer and check if the issue persists.
9] WSL Stops working with Error 0x80070003
If WSL stops with this error code 0x80070003, solve it with this guide.
10] Display language changing in WSL
WSL automatically changes the Ubuntu locale, for it to match the language of your Windows computer. If you are not a fan of this move, use the following command to set the display language according to your needs.
Note: The following command will change the language to en-US.
sudo update-locale LANG=en_US.UTF8
Do this and check if it fixes the issue.
11] Installation issues after Windows system restore
If you are facing Installation issues after Windows system restore, try deleting the Windows Subsystem for Linux folder. The following is its path.
%windir%\System32\Tasks\Microsoft\Windows\Windows Subsystem for Linux
Restart your computer, reinstall Bash and check if it fixes the issue.
12] No internet access in WSL
Many users have reported that they are not able to access the Internet in WSL. However, the solution might be easier than you think. This happens because of any third-party antivirus that you may have. As the firewall blocks the Internet. So, to fix this, remove the anti-virus and you will be good to go.
13] Permission Denied when using Ping
If you are not able to Ping in WSL then this means that you don’t have administrative privilege. So, you need to run Ubuntu and Linux with administrative privilege or Bash.exe on your command line interpreter with administrative privilege.
Hopefully, this will fix the issue easily.
14] Unable to boot after installing WSL 2
The reason why you are unable to boot after installing WSL 2 is still uncanny but Microsoft is trying to work on an update to fully diagnose the issue. However, there are two things that you can do and see if it fixes the issue.
15] Not able to run Windows Commands inside a distributor
There are a few distributors in Windows Store that are not completely optimized to run all Windows Commands. You may get any of the following errors.
-bash: powershell.exe: command not found
powershell.exe /c start
To fix this error, run the following command.
echo $PATH
Now, check if the output includes “/mnt/c/Windows/system32”, if you are facing the error, then most probably the path won’t be there.
Now, check your Profile settings by
cat /etc/profile
Now, check if a Path assignment starts with “#”, if it does, comment out the block. Also, check if wsl.conf is present and make sure that it doesn’t have appendWindowsPath=false
. If it does, comment it out.
After doing this, you need to restart distribution. You can use the following command to do that.
wsl -t <name of the distributor>
or
wsl --shutdown
Hopefully, the issue will be fixed.
16] ICS is disabled
A WSL can not operate without ICS or Internet Connection Sharing. The Host Network Service (HNS) uses the ICS to build a fundamental virtual network for WSL 2 to create NAT, DNS, DHCP, and host connection sharing.
To fix the error, we need to enable ICS. So, follow the given steps to enable ICS.
- Launch Services from the Start Menu.
- Double-click on Internet Connection Sharing (ICS), and click Start if it’s stopped.
- Finally, click Apply > Ok.
You should also edit some policies. So, launch Group Policy Editor and navigate to the following location.
Computer Configuration > Administrative Templates > Network > Network Connections
And disable the following policies.
- Prohibit installation and configuration of Network Bridge on your DNS domain network
- Prohibit the use of Internet Connection Firewall on your DNS domain network
- Prohibit the use of Internet Connection Sharing on your DNS domain network
- Require domain users to elevate when setting a network’s location
17] Bash is hung
When Bash hangs or deadlocks and stops responding to your input you can either restart your machine as that will fix the error or report a memory dump. The latter may lead to a system crash, so, save your work prior to reporting.
18] OpenSSH-Server connection issues
If you are seeing any OpenSSF-Server connection issue, the first thing you need to do is to check if the OpenSSH-Server is running. You can use the following command to do that.
sudo service ssh status
If it’s not running, use the following command to start the service.
sudo service ssh start
If it’s running, you should restart the service with the following command and check if it fixes the issue.
sudo service ssh restart
If it’s unable to fix the issue, try to start SSHD in debug mode. Before that, use the following command to stop SSH service.
sudo service ssh stop
Now, use the following command to start SSHD in debug mode.
sudo /usr/sbin/sshd -d
Hopefully, this fixes the error.
19] The referenced assembly could not be found
Many users are encountering “The referenced assembly could not be found” when they try to enable WSL additional feature. If you are one of them, try enabling Windows Subsystem for Linux from Control Panel and updating your computer. Hopefully, that will fix the error.
20] Correct (SSH related) permission errors
If you are seeing the following error, thread this section for the solution.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for '/home/artur/.ssh/private-key.pem' are too open.
To fix this issue, Microsoft suggests that you go to /etc/wsl.conf file and append the following:
[automount]
enabled = true
options = metadata,uid=1000,gid=1000,umask=0022
This will fix the error. Before, doing this, make sure you have adequate permission.
These were some of the Windows Subsystem for Linux Error Messages and Codes and their troubleshooting tips. We hope that they help you fix WSL Errors, Problems, and Issues.