Too many storage controllers of the type in Vagrant

0

I'm going to create 7 servers with 2 disks each. Here is the vagrant file. This is my first configuration of a multiple machines environments. Hence I haven't any experience in creating environments from scratch.

This is the error I got

Command: ["storagectl", "cc27c05a-63da-4e02-ab73-86843032e387", "--name", "SATA Controller", "--add", "sata"]

Stderr: VBoxManage: error: Too many storage controllers of this type
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component StorageController, interface IStorageController, callee nsISupports
VBoxManage: error: Context: "AddStorageController(Bstr(pszCtl).raw(), StorageBus_SATA, ctl.asOutParam())" at line 1044 of file VBoxManageStorageController.cpp

Vagrafile

Vagrant.configure(2) do |config|

    config.vm.box = "ubuntu/trusty64"

    config.vm.provider "virtualbox" do |vb|
        vb.customize ["modifyvm", :id, "--memory", "2048", "--cpus", "1"]
        vb.customize ["storagectl", :id, "--name", "SATA Controller", "--add", "sata"]
    end

    config.vm.define "machine1" do |machine1|

        machine1.vm.hostname = "machine1"

        machine1.vm.provider "virtualbox" do |vb|
            vb.customize ["createhd",  "--filename", "machine1_disk0", "--size", 4096]
            vb.customize ["createhd",  "--filename", "machine1_disk1", "--size", 4096]
            vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--type", "hdd", "--medium", "machine1_disk0.vdi"]
            vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 2, "--type", "hdd", "--medium", "machine1_disk1.vdi"]
        end

        machine1.vm.network "private_network", ip: "192.168.10.10"
        machine1.vm.network "private_network", ip: "192.168.10.15"
    end

    config.vm.define "machine2" do |machine2|

        machine2.vm.hostname = "machine2"

        machine2.vm.provider "virtualbox" do |vb|
            vb.customize ["createhd",  "--filename", "machine2_disk0", "--size", 4096]
            vb.customize ["createhd",  "--filename", "machine2_disk1", "--size", 4096]
            vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--type", "hdd", "--medium", "machine2_disk0.vdi"]
            vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 2, "--type", "hdd", "--medium", "machine2_disk1.vdi"]
        end

        machine2.vm.network "private_network", ip: "192.168.10.20"
        machine2.vm.network "private_network", ip: "192.168.10.25"
    end

    config.vm.define "machine3" do |machine3|

        machine3.vm.hostname = "machine3"

        machine3.vm.provider "virtualbox" do |vb|
            vb.customize ["createhd",  "--filename", "machine3_disk0", "--size", 4096]
            vb.customize ["createhd",  "--filename", "machine3_disk1", "--size", 4096]
            vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--type", "hdd", "--medium", "machine3_disk0.vdi"]
            vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 2, "--type", "hdd", "--medium", "machine3_disk1.vdi"]
        end

        machine3.vm.network "private_network", ip: "192.168.10.30"
    end

    config.vm.define "machine4" do |machine4|

        machine4.vm.hostname = "machine4"

        machine4.vm.provider "virtualbox" do |vb|
            vb.customize ["createhd",  "--filename", "machine4_disk0", "--size", 4096]
            vb.customize ["createhd",  "--filename", "machine4_disk1", "--size", 4096]
            vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--type", "hdd", "--medium", "machine4_disk0.vdi"]
            vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 2, "--type", "hdd", "--medium", "machine4_disk1.vdi"]
        end

        machine4.vm.network "private_network", ip: "192.168.10.40"
    end

    config.vm.define "machine5" do |machine5|

        machine5.vm.hostname = "machine5"

        machine5.vm.provider "virtualbox" do |vb|
            vb.customize ["createhd",  "--filename", "machine5_disk0", "--size", 4096]
            vb.customize ["createhd",  "--filename", "machine5_disk1", "--size", 4096]
            vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--type", "hdd", "--medium", "machine5_disk0.vdi"]
            vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 2, "--type", "hdd", "--medium", "machine5_disk1.vdi"]
        end

        machine5.vm.network "private_network", ip: "192.168.10.50"
    end

    config.vm.define "machine6" do |machine6|

        machine6.vm.hostname = "machine6"

        machine6.vm.provider "virtualbox" do |vb|
            vb.customize ["createhd",  "--filename", "machine6_disk0", "--size", 4096]
            vb.customize ["createhd",  "--filename", "machine6_disk1", "--size", 4096]
            vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--type", "hdd", "--medium", "machine6_disk0.vdi"]
            vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 2, "--type", "hdd", "--medium", "machine6_disk1.vdi"]
        end

        machine6.vm.network "private_network", ip: "192.168.10.60"
    end

    config.vm.define "machine7" do |machine7|

        machine7.vm.hostname = "machine7"

        machine7.vm.provider "virtualbox" do |vb|
            vb.customize ["createhd",  "--filename", "machine7_disk0", "--size", 4096]
            vb.customize ["createhd",  "--filename", "machine7_disk1", "--size", 4096]
            vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--type", "hdd", "--medium", "machine7_disk0.vdi"]
            vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 2, "--type", "hdd", "--medium", "machine7_disk1.vdi"]
        end

        machine7.vm.network "private_network", ip: "192.168.10.70"
    end

end
virtual-machine
vagrant
virtualbox
vagrantfile
asked on Stack Overflow Jan 10, 2015 by Mazzy

2 Answers

1

The issue is that your box already have existing SATA storage controller, so you shouldn't try to add new one in the beginning of your provision (you cannot add multiple SATA storage controllers).

answered on Stack Overflow Jan 12, 2015 by m1keil
0

If your box already contains a SATA Controller, you can fix changing controller type to SAS:

vb.customize ["storagectl", :id, "--name", "SAS Controller", "--add", "sas", '--portcount', 2]

and change controller name reference for every disk you attach to it:

vb.customize ["storageattach", :id, "--storagectl", "SAS Controller", "--port", 1, "--type", "hdd", "--medium", "machine7_disk0.vdi"]

with SAS controller I solved this issues in vagrant and virtualbox.

answered on Stack Overflow Mar 27, 2018 by miticojo

User contributions licensed under CC BY-SA 3.0