1

Objective

Create a VM with Vagrant and Virtualbox with 2 disks for setting a raid1 later.

My Vagrantfile

# -*- 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

Showing directory tree

.
|-- Vagrantfile
`-- Vagrantfile.b

0 directories, 2 files

I have created a directory for this scenario, and I show you the output of a tree -a so you can see that all is alright.

Error I get after vagrant up

I'll show you the complete output, so you can see the whole process + error

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.

I can't understand why I get this error, if as you can see, I deleted all the files again from previous creations with errors.
BUT there is something funny happening. If after getting this error, I execute tree -a again, look what I get:

.
|-- .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

As you can notice, one of the 2 disks have been created (but I'm pretty sure this is not working because the Sata controller and the link to the SATA controller has not been executed).
I'm pretty sure this is a big clue of what it's happening here, but I can't see how can I solve this situation.

0 Answers0