1

客观的

使用 Vagrant 和 Virtualbox 创建一个带有 2 个磁盘的 VM,以便稍后设置 raid1。

我的流浪文件

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

Vagrant.configure("2") do |config|

  config.vm.box = "debian/buster64"

  disco1 = 'disco1.vdi'
  disco2 = 'disco2.vdi'

  config.vm.provider "virtualbox" do |vb|
    # Create disk files if they haven't been created
    if not File.exists?(disco1)
      vb.customize ['createhd', '--filename', disco1, '--variant', 'Fixed', '--size', 10 * 1024]
    end
    if not File.exists?(disco2)
      vb.customize ['createhd', '--filename', disco2, '--variant', 'Fixed', '--size', 10 * 1024]

      # Add SATA controller with 4 ports
      vb.customize ['storagectl', :id, '--name', 'SATAController', '--add', 'sata', '--portcount', 4]

      # Attach the disks to the SATA controller
      vb.customize ['storageattach', :id,  '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', disco1]
      vb.customize ['storageattach', :id,  '--storagectl', 'SATA Controller', '--port', 2, '--device', 0, '--type', 'hdd', '--medium', disco2]
    end
  end


end

显示目录树

.
|-- Vagrantfile
`-- Vagrantfile.b

0 directories, 2 files

我已经为这个场景创建了一个目录,我向你展示了 a 的输出,tree -a这样你就可以看到一切都很好。

我得到的错误vagrant up

我会给你看完整的输出,这样你就可以看到整个过程+错误

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'debian/buster64'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: scenario_raid1_default_1569617045977_67208
==> 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: Running 'pre-boot' VM customizations...
A customization command failed:

["createhd", "--filename", "disco1.vdi", "--variant", "Fixed", "--size", 10240]

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: ["createhd", "--filename", "disco1.vdi", "--variant", "Fixed", "--size", "10240"]

Stderr: 0%...
Progress state: VBOX_E_FILE_ERROR
VBoxManage: error: Failed to create medium
VBoxManage: error: Could not create the medium storage unit '/home/atlas/Documents/vagrant/scenario_raid1/disco1.vdi'.
VBoxManage: error: VDI: cannot create image '/home/atlas/Documents/vagrant/scenario_raid1/disco1.vdi' (VERR_ALREADY_EXISTS)
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MediumWrap, interface IMedium
VBoxManage: error: Context: "RTEXITCODE handleCreateMedium(HandlerArg*)" at line 462 of file VBoxManageDisk.cpp
>

Please fix this customization and try again.

我不明白为什么会出现此错误,如果如您所见,我再次从以前的创建中删除了所有有错误的文件。
但是发生了一些有趣的事情。如果在收到此错误后,我tree -a再次执行,看看我得到了什么:

.
|-- .vagrant
|   |-- machines
|   |   `-- default
|   |       `-- virtualbox
|   |           |-- action_set_name
|   |           |-- creator_uid
|   |           |-- id
|   |           |-- index_uuid
|   |           `-- vagrant_cwd
|   `-- rgloader
|       `-- loader.rb
|-- Vagrantfile
|-- Vagrantfile.b
`-- disco1.vdi

5 directories, 9 files

如您所见,已创建了 2 个磁盘之一(但我很确定这不起作用,因为尚未执行 SATA 控制器和到 SATA 控制器的链接)。
我很确定是这里发生的事情的一个重要线索,但我不知道如何解决这种情况。

4

0 回答 0