Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add storage settings to Vagrant file?

I have created a VM using vagrant and tried to insert a cd, when realized that there is no such device to read it installed.

An option would be to go to my provider UI and through settings add what I need.

I want to know if there is any way to insert this setting (add a cdrom device to VM) into the vagrant file.

My provider is VirtualBox.

>>UPDATE

Mixing info from here and here, and extending some code example already existing in Vagrantfile I came up with

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 
    ...   
    ...   
    config.vm.provider :virtualbox do |vb|
         vb.customize ["storagectl", :id, "--name", "IDEController", "--add", "ide"]
         vb.customize ["storageattach", :id, "--storagectl", "IDEController", "--port", "0", "--device", "0", "--type", "dvddrive", "--medium", "none"]      
         vb.customize ["modifyvm", :id, "--boot1", "disk", "--boot2", "dvd"]
    end
    ...
    ...   
end

in the Vagrantfile.

The problem is that now, when attempting to perform vagrant reload, I get

VBoxManage.exe: error: No storage device attached to device slot 0 on port 0
like image 643
Michael Avatar asked Feb 24 '14 11:02

Michael


Video Answer


1 Answers

--medium none is to telling VirtualBox to delete that DVD, please use --medium emptydrive.

See this link https://groups.google.com/forum/#!topic/vagrant-up/Z_KruTTN0vk and medium help:

--medium

Specifies what is to be attached. The following values are supported:

  • "none": Any existing device should be removed from the given slot.
  • "emptydrive": For a virtual DVD or floppy drive only, this makes the device slot behaves like a removable drive into which no media has been inserted.
like image 104
L.H Avatar answered Oct 19 '22 03:10

L.H