【问题标题】:Error while running Vagrant up运行 Vagrant 时出错
【发布时间】:2017-03-16 01:49:54
【问题描述】:

最初,我有 8 台 vagrant 机器在运行,但出现了问题。所以我删除了 ~/VirtualBox\ VMs 文件夹中的 vms,并将备份的 .vmdk 文件放在同一位置。 然后我尝试运行 vagrant... 但我收到以下错误

将机器“virtual-am1”与“virtualbox”提供程序一起启动...

==> virtual-am1: Importing base box 'centos653'...
==> virtual-am1: Matching MAC address for NAT networking...
==> virtual-am1: Setting the name of the VM: vagrant_virtual-am1_1478100170176_83326
==> virtual-am1: Clearing any previously set network interfaces...
==> virtual-am1: Preparing network interfaces based on configuration...
    virtual-am1: Adapter 1: nat
    virtual-am1: Adapter 2: bridged
==> virtual-am1: Forwarding ports...
    virtual-am1: 22 (guest) => 2203 (host) (adapter 1)
==> virtual-am1: Running 'pre-boot' VM customizations...
   A customization command failed:

["modifyvm", :id, "--name", "virtual-am1"]

The following error was experienced:

#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["modifyvm", "6dd13964-e648-40cd-932e-3e18be375d31", "--name", "virtual-am1"]

Stderr: VBoxManage: error: Could not rename the directory '/home/vagrant/VirtualBox VMs/vagrant_virtual-am1_1478100170176_83326' to '/home/vagrant/VirtualBox VMs/virtual-am1' to save the settings file (VERR_ALREADY_EXISTS)

VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SessionMachine, interface IMachine, callee nsISupports

VBoxManage: error: Context: "SaveSettings()" at line 2788 of file VBoxManageModifyVM.cpp

>Please fix this customization and try again.

这就是我的 Vagrantfile 的样子... 我们有一个自定义的 Vagrant 文件

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

#Parse nodes config file
nodes_config = (JSON.parse(File.read("nodes.json")))['nodes']

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.ssh.insert_key = false

  config.vm.box = "centos653"
  config.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box"
 # config.vm.provision :shell, path: "bootstrap.sh"

  nodes_config.each do |node|
    node_name   = node[0] # name of node
    node_values = node[1] # content of node

    config.vm.define node_name do |config|
      # configures all forwarding ports in JSON array
      ports = node_values['ports']
      ports.each do |port|
        config.vm.network :forwarded_port,
          host:  port[':host'],
          guest: port[':guest'],
          id:    port[':id']
      end

      config.vm.synced_folder "/bits", "/vagrant/bits"
      config.vm.synced_folder "../virtual", "/vagrant/virtual"

      config.vm.hostname = node_values[':hostname']
      #config.vm.network :private_network, ip: node_values[':ip']
      config.vm.network "public_network", bridge: 'enp134s1f0', ip: node_values[':ip']

      config.vm.provider :virtualbox do |vb|
        vb.customize ["modifyvm", :id, "--memory", node_values[':memory']]
        vb.customize ["modifyvm", :id, "--name", node_values[':node']]
        vb.customize ["modifyvm", :id, "--cpus", 8]
      end

    end
  end
end

这就是我的 nodes.json 文件的样子

{
  "nodes": {
    "virtual-am1": {
      ":node": "virtual-am1",
      ":ip": "192.168.1.50",
      ":hostname": "am1.onefederation.org",
      "ports": [
        {
          ":host": 2203,
          ":guest": 22,
          ":id": "ssh"
        }
      ],
      ":memory": 1024
    },
  }
}

请帮忙!!!

【问题讨论】:

  • 您能否提供更多有关问题所在的信息?
  • 最初我有 vm 正在运行,我有所有 vm 的 .vmdk 文件作为备份。我在所有虚拟机上都运行了 openAM,但 OpenAM 的配置出现了问题。所以我决定销毁所有的 Vagrant 机器,并从我之前制作的备份中恢复它们。我使用 Vagrant destroy 命令删除了所有虚拟机。 /home/vagrant/Virtual Box/vms 中没有虚拟机。后来我将包含来自备份的 .vmdk 文件的 vm 文件夹放在同一位置(/home/vagrant/Virtual Box/vms)并运行 vagrant。运行 vagrant up 后出现上述错误。

标签: vagrant virtual-machine virtualbox vagrantfile


【解决方案1】:

我遇到了这个错误,你可以使用这个修复:

删除vagrant中的文件夹项目

rm -rf /home/protobox/VirtualBox VMs/project_folder

进入项目文件夹:

cd /var/www/project_folder

然后重启vagrant:

vagrant destroy**maybe more**`vagrant destroy -f`
vagrant reload

终于开始流浪

vagrant up
vagrant ssh

或者你可以参考这里:http://getprotobox.com/docs/issues/vbox_rename

祝你好运!

【讨论】:

    猜你喜欢
    • 2016-09-04
    • 2016-07-06
    • 1970-01-01
    • 1970-01-01
    • 2023-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-18
    相关资源
    最近更新 更多