如何让 Oracle vm VirtualBox 6.0 和 wsl 同时工作

how to get Oracle vm VirtualBox 6.0 and wsl working at the same time

当我打开 Windows 子系统时 Windows 功能中的 Linux 选项打开或关闭

VirtualBox 每次 i 运行 a vm

都会出错

调用 WHvSetupPartition 失败:ERROR_SUCCESS (Last=0xc000000d/87) (VERR_NEM_VM_CREATE_FAILED)。 结果代码:E_FAIL (0x80004005) 组件:ConsoleWrap 界面:IConsole {872da645-4a9b-1727-bee2-5585105b9eed}

有没有办法在不关闭 wsl 的情况下修复 VirtualBox 错误

我找到了!经过大量研究和反复试验,这使我能够在 Windows 10 上的 VirtualBox 中 运行 虚拟机,并安装了 Linux 的 Windows 子系统:

在提升的(管理员)cmd.exe 或 PowerShell 中,执行:

bcdedit /set hypervisorlaunchtype off

并确保 Hyper-V 和 Windows 沙箱在 Windows 功能中被禁用(您可以通过在命令提示符下输入 OptionalFeatures.exe 或通过控制面板进入) ).

此外,应该在 BIOS 中启用虚拟化选项,我 认为(我现在没有时间测试)"Virtual Machine Platform" 和 "Windows Hypervisor Platform" 应该启用。

VirtualBox 6.0.14,Windows 版本 10.0.18362.356。

2019 年 11 月,我将我的 Windows10 family 升级到版本 1909(运行 winver 检查)。我想使用 WSL2。

然后我无法 运行 Oracle Virtualbox 中的虚拟机:

调用 WHvSetupPartition 失败:ERROR_SUCCESS (Last=0xc000000d/87) (VERR_NEM_VM_CREATE_FAILED).

我必须检查 "Turn Windows features ON or OFF" 中的 "Plateforme Hyper-V" 一切顺利。

VirtualBox + WSL2(在 Windows 10 和 11 上)

可以在 Windows 10 和 Windows 11 上同时安装 VirtualBox 和 WSL2 运行ning!请注意,当 运行 两者并行时,VirtualBox 只能在其较慢的 软件虚拟化模式 .

中 运行ning

要设置两个系统,请确保在您的 BIOS 中启用了虚拟化选项!

  • Virtual Box - 在您的机器上安装最新版本 (official download)
  • WSL2 - 只需在提升的 PowerShell 或 CMD (official docs)
  • 中 运行 命令 wsl --install

疑难解答

必要的Windows功能?

通过命令行安装 WSL 应该会自动打开以下 Windows 功能:

  • 虚拟机平台
  • Windows Linux
  • 的子系统

WSL 在底层使用 Hyper-V 架构,但不需要启用实际的 Hyper-V 功能。换句话说:WSL 使用 Hyper-V 架构但不使用 Hyper-V 功能(感谢@Cito)。

Enable/Disable Windows 特点

您可以通过以下方式查找和编辑 Windows 特征:

  • 打开 控制面板 > 程序 > 打开或关闭 Windows 功能,或
  • 在 CMD 或 PowerShell 终端中输入 OptionalFeatures.exe

使用 Windows 主页?

如果您 运行宁 Windows 家庭,您的机器上可能没有安装某些功能。要手动添加这些虚拟化功能,请遵循 this tutorial.

WSL 停止工作了?

如果您已经安装了 WSL 并对 Windows 功能进行了更改,则 WSL 可能已经停止工作。尤其是当 WSL 是通过一种旧方法(而不是通过 wsl --install 命令行)安装的时候。要修复 WSL 安装,您可以执行以下操作:

  1. 从您的系统中完全卸载并删除 WSL(如果需要,请备份您的文件!)
  2. 停用所有虚拟化功能
  3. 重启机器
  4. 通过命令行全新安装 WSL wsl --install
  5. 再次重启机器

VirtualBox VM 速度慢?

如果你看到这个绿海龟符号 in the guest window's status bar, VirtualBox is running in software virtualization mode (which is really slow!). The hardware virtualization mode would be displayed with this blue symbol

当 运行在软件模式下运行时,原因很可能是活动的 WSL 设置,它依赖于 Hyper-V 架构。另一个原因可能是要打开的 Hyper-V 功能。要返回硬件虚拟化模式,请确保关闭以下功能:

  • Hyper-V
  • Windows 管理程序平台

并且 hypervisorlaunchtype 在 Windows 引导配置数据 (BCD) 存储中设置为 off。为此,运行 从提升的命令行执行以下命令:

bcdedit /set hypervisorlaunchtype off

更改 BCD 后,需要重新启动。


更多信息

更多信息: