1.背景
Vagrant 在通过 VirtualBox 启动 CentOS 虚拟机时失败,报下列错误:
C:\Users\ymcfy>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'centos/7' version '2004.01' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["startvm", "d96e4abe-4361-47f8-a682-a1766d0b0f2a", "--type", "headless"]
Stderr: VBoxManage.exe: error: Failed to get device handle and/or partition ID for 00000000017c43c0 (hPartitionDevice=0000000000000aa9, Last=0xc0000002/1) (VERR_NEM_VM_CREATE_FAILED)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole
2.原因
(1)当前windows开启了hype-v
(2)使用wsl时开启了虚拟机
3.解决步骤
(1)用管理员启动Powershell,务必用管理员启动
(2)执行下列指令,关闭hyper-v
bcdedit /set hypervisorlaunchtype off
(3)执行下列指令,关闭wsl
Disable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
在上述步骤完成后,此问题即可解决。可通过再次使用vagrant up测试