无法在Ubuntu上启动Vagrant VirtualBox

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法在Ubuntu上启动Vagrant VirtualBox相关的知识,希望对你有一定的参考价值。

我只是想尝试启动一些Windows流浪的VirtualBox虚拟机。

vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> 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: 5985 (guest) => 55985 (host) (adapter 1)
    default: 5986 (guest) => 55986 (host) (adapter 1)
    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", "9100d42a-152f-41c7-81f6-c3cc667240a7", "--type", "headless"]

Stderr: VBoxManage: error: The virtual machine 'MSEdgeWin10_preview17_default_1519585578822_41955' has terminated unexpectedly during startup with exit code 1 (0x1)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine

Vagrant版本:Vagrant 2.0.2 VirtualBox版本:5.2.6r120293 lsb_release -a:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 17.10
Release:    17.10
Codename:   artful

流浪者名单:

IE11-win81              (virtualbox, 0)
msedge-win10-16         (virtualbox, 0)
msedge-win10-17-preview (virtualbox, 0)

Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  config.vm.box = "msedge-win10-17-preview"

  config.vm.boot_timeout = 500

  config.vm.communicator = "winrm"
  config.winrm.username = "IEUser"
  config.winrm.password = "Passw0rd!"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
  # such as FTP and Heroku are also available. See the documentation at
  # https://docs.vagrantup.com/v2/push/atlas.html for more information.
  # config.push.define "atlas" do |push|
  #   push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
  # end

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

UPDATE

我添加了一个配置来让VirtualBox加载GUI。现在我从GUI弹出窗口中收到此错误:

RTR3InitEx failed with rc=-1912 (rc=-1912)

The VirtualBox kernel modules do not match this version of VirtualBox. The installation of VirtualBox was apparently not successful. Executing

'/sbin/vboxconfig'

may correct this. Make sure that you do not mix the OSE version and the PUEL version of VirtualBox.

where: supR3HardenedMainInitRuntime what: 4 VERR_VM_DRIVER_VERSION_MISMATCH (-1912) - The installed support driver doesn't match the version of the user.

这是我使用的配置(添加到以前的配置):

config.vm.provider 'virtualbox' do |v|
          v.gui = true
end
答案

问题:安装了太多版本的VirtualBox。

我使用StackExchange的这些问题/答案来帮助我:

我怎么发现:

dpkg -l '*virtualbox*' | grep ^i

然后我用这个命令删除VB的包:

sudo apt autoremove --purge virtualbox

还有其他包含VB名称,我删除了所有这些包。

然后我更新了...以防万一:

sudo apt update

然后只需重新安装VB。

以下是确保不再存在导致冲突的错误配置的最后步骤。

删除.vagrant目录:

rm -r .vagrant

删除VirtualBox.xml配置文件并将其替换为干净版本:

rm /home/$USER/.config/VirtualBox/VirtualBox.xml
cp /home/$USER/.config/VirtualBox/VirtualBox.xml-prev /home/$USER/.config/VirtualBox/VirtualBox.xml

从Vagrant中删除一些缓存文件:

rm /home/$USER/.vagrant.d/data/machine-index/index.lock
rm /home/$USER/.vagrant.d/data/machine-index/index

清理VB VM。

首先,您需要获取UUID:

VBoxManage list vms

EG

"MSEdgeWin10_preview17_default_1519845470831_93278" {060622eb-b903-4287-8ac7-fcdf9233a6b9}
"MSEdgeWin10_preview17_default_1519850217620_30972" {e2ca66bc-b64e-4fba-89e5-688c2a2a5fc3}

然后你只需用UUID删除它们:

VBoxManage unregistervm 060622eb-b903-4287-8ac7-fcdf9233a6b9
VBoxManage unregistervm e2ca66bc-b64e-4fba-89e5-688c2a2a5fc3

然后我开始流浪汉:

vagrant up

如果您想要更大的视图,您可能还想在Vagrantfile中扩展vram。

EG

config.vm.provider 'virtualbox' do |v|
    v.gui = true
    v.customize [
      "modifyvm", :id,
      "--vram", "23"
    ]
end

23是MB,这似乎是VB的推荐。

以上是关于无法在Ubuntu上启动Vagrant VirtualBox的主要内容,如果未能解决你的问题,请参考以下文章

由于内存不足,无法在vagrant ubuntu框中启动zookeeper服务器

无法在Win系统上的Ubuntu虚拟机中安装Scrapy(Shell)

在 Windows 7 主机上使用活动 *** 连接启动时,vagrant 配置的 virtualbox 无法访问互联网

解决Ubuntu启动错误一例

Vagrant box add - 无法连接到cloud-images.ubuntu.com端口443:超时

vagrant synced文件夹在virtualbox上不能实时工作