我有 Windows 11,WSL 运行良好,直到我不得不做一个电脑重置现在尝试从头开始再次安装它。这是我现在得到的结果(经过多次 WSL 安装尝试):
PS > wsl --install
Windows Subsystem for Linux is already installed.
The following is a list of valid distributions that can be installed.
Install using 'wsl.exe --install <Distro>'.
NAME FRIENDLY NAME
Ubuntu Ubuntu
Debian Debian GNU/Linux
kali-linux Kali Linux Rolling
SLES-12 SUSE Linux Enterprise Server v12
SLES-15 SUSE Linux Enterprise Server v15
Ubuntu-18.04 Ubuntu 18.04 LTS
Ubuntu-20.04 Ubuntu 20.04 LTS
OracleLinux_8_5 Oracle Linux 8.5
OracleLinux_7_9 Oracle Linux 7.9
PS > wsl --install Ubuntu-20.04
Installing: Ubuntu 20.04 LTS
Ubuntu 20.04 LTS has been installed.
Launching Ubuntu 20.04 LTS...
PS > wsl list
Windows Subsystem for Linux has no installed distributions.
Use 'wsl.exe --list --online' to list available distributions
and 'wsl.exe --install <Distro>' to install.
Distributions can also be installed by visiting the Microsoft Store:
https://aka.ms/wslstore
Error code: Wsl/Service/CreateInstance/GetDefaultDistro/WSL_E_DEFAULT_DISTRO_NOT_FOUND
如果我运行 Ubuntu 应用程序,我会得到:
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80370114
Error: 0x80370114 The operation could not be started because a required feature is not installed.
Press any key to continue...
在“打开或关闭 Windows 功能”下我已启用:
[x] Virtual Machine Platform
[x] Windows Hypervisor Platform
[x] Windows Subsystem for Linux
顺便说一句,我后来只是作为实验才打开了“Windows Hypervisor Platform”。我在GitHub以及其他相关内容,vmcompute.exe
但我的系统上没有,我需要安装它吗?如果需要,如何安装?!
PS > ls C:\Windows\System32\vm*
Directory: C:\Windows\System32
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 07/05/2022 06:20 50528 VmApplicationHealthMonitorProxy.dll
-a---- 21/11/2022 19:41 79896 vmbuspipe.dll
-a---- 07/05/2022 06:20 270336 vmdevicehost.dll
-a---- 07/05/2022 06:20 87400 vmictimeprovider.dll
-a---- 07/05/2022 06:20 487424 vmrdvcore.dll
尽管已经启用,也尝试了接受的答案在类似的问题上,但没有区别:
PS > dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Deployment Image Servicing and Management tool
Version: 10.0.22621.1
Image Version: 10.0.22621.819
Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.
PS > dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Deployment Image Servicing and Management tool
Version: 10.0.22621.1
Image Version: 10.0.22621.819
Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.
那么,解决方案是什么呢?论坛解答没有帮助我,而且MS 文档听起来所需要的只是魔法wsl --install
。
系统信息:
Edition Windows 11 Home
Version 22H2
OS build 22621.819
Experience Windows Feature Experience Pack 1000.22636.1000.0
任何建议都值得赞赏,否则我会稍后分享我找到的解决方案。现在要安装一些更新,看看是否有帮助。
答案1
安装了 Windows 更新,重新启动后 Ubuntu 安装恢复。现在 WSL 可以正常工作了!
现在我有:
PS > ls C:\Windows\System32\vmcompute*
Directory: C:\Windows\System32
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 21/11/2022 19:41 796000 vmcompute.dll
-a---- 21/11/2022 19:41 4158848 vmcompute.exe
-a---- 07/05/2022 08:16 42344 vmcomputeeventlog.dll
真的很简单,但我很高兴,希望它对某人有帮助。
答案2
为了防止其他人通过搜索找到这里,我想我会添加除了提到的大部分内容之外我还需要做的事情,因为这似乎是众多重复问题中信息最丰富的问题。
当我卡在错误处时0x80370114
,我需要取消选中Virtual Machine Platform
、Windows Hypervisor Platform
和
Windows Subsystem for Linux
中的选项Turn Windows features On or Off
。然后点击Apply
,跳过建议重新启动,然后再次将它们全部打开,然后Apply
,这一次和重新开始。
完成此操作后,我点击0x80370102 错误,我通过将虚拟机管理程序启动类型重新设置为自动(我在之前的一次绝望的故障排除过程中将其关闭)解决了这个问题:
bcdedit /set hypervisorlaunchtype Auto
重新启动后,WSL 命令按预期工作。
答案3
我必须在 BIOS 中启用 VM 利用率。尽管 WSL2 不需要它,但我也启用了 HyperV。
然后它就起作用了。
答案4
我也有同样的情况。
PS> wsl --install -d Ubuntu
PS> wsl list
它报告命令错误wsl list
。
你可以试试:
PS> ubuntu
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: xxx
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.79.1-microsoft-standard-WSL2 x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
This message is shown once a day. To disable it please create the
/home/xxx/.hushlogin file.
进入子系统后退出ubuntu
,重新执行命令wsl list
,即可正常工作!