我有一台 Ubuntu 17.04 机器,安装了 VirtualBox 和 libvirt/kvm-qemu。
每当我尝试使用 VirtualBox 提供者启动 Vagrant 盒子时,我都会收到以下错误:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/xenial64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/xenial64' is up to date...
==> default: A newer version of the box 'ubuntu/xenial64' is available! You currently
==> default: have version '20170626.0.0'. The latest is version '20170717.0.0'. Run
==> default: `vagrant box update` to update.
==> default: Setting the name of the VM: mainframe_default_1500383484218_22222
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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", "ab19fdfd-349e-40d0-b540-aa130b9e1b72", "--type", "headless"]
Stderr: VBoxManage: error: VT-x is being used by another hypervisor (VERR_VMX_IN_VMX_ROOT_MODE).
VBoxManage: error: VirtualBox can't operate in VMX root mode. Please disable the KVM kernel extension, recompile your kernel and reboot (VERR_VMX_IN_VMX_ROOT_MODE)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component ConsoleWrap, interface IConsole
当 kvm-qemu 也存在时,有没有办法使用 VirtualBox 和 Vagrant?
这是我的Vagrantfile
:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.network "private_network", ip: "192.168.66.10"
config.vm.provision "ansible" do |ansible|
ansible.playbook = 'playbook.yml'
end
end
我不想使用 libvirt 提供程序,因为它的框较少,而且我必须手动编辑我使用的每个 Vagrantfile。
当 VirtualBox 和 libvirt/kvm-qemu 都存在时,如何将 Vagrant 与 VirtualBox 一起使用?
答案1
我找到了答案,有点偶然。可以同时安装两者,但不可能让它们同时运行虚拟机。
如果我关闭 libvirt 中的每个虚拟机,那么我就可以运行 Vagrant 和 VirtualBox。如果我需要 libvirt 的机器,那么我必须关闭每个 VitrualBox 虚拟机。