adding cdrom/dvd to base box that omits it

4,220 views
Skip to first unread message

Vince Skahan

unread,
Jun 18, 2015, 3:06:19 PM6/18/15
to vagra...@googlegroups.com
I'm trying to come up with a Vagrantfile pre-boot customization to do the following:
  • add a cdrom/dvd device to the base box (which doesn't define one)
  • mount the virtual box linux guest additions to that device

Here's what I tried to add:


    vb.customize "pre-boot", [
       "storageattach", :id,
       "--storagectl", "IDE Controller",
        "--port", "1",
       "--device", "0",
       "--type", "dvddrive",
       "--medium", "none",
       ]


When I try to 'vagrant up' it blows up immediately, complaining:


A customization command failed:

["storageattach", :id, "--storagectl", "IDE Controller", "--port", "1", "--device", "0", "--type", "dvddrive", "--medium", "none"]

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: ["storageattach", "1c4310b6-d5ef-4e79-bc34-ef6dcdb32b69", "--storagectl", "IDE Controller", "--port", "1", "--device", "0", "--type", "dvddrive", "--medium", "none"]

Stderr: VBoxManage.exe: error: No storage device attached to device slot 0 on port 1 of controller 'IDE Controller'
VBoxManage.exe: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component SessionMachine, interface IMachine, callee IUnknown
VBoxManage.exe: error: Context: "DetachDevice(Bstr(pszCtl).raw(), port, device)" at line 381 of file VBoxManageStorageController.cpp
>

Please fix this customization and try again.


I'd love to fix it.  Any pointers to help decipher what it wants ?  

Any help much appreciated....


Alvaro Miranda Aguilera

unread,
Jun 18, 2015, 10:54:33 PM6/18/15
to vagra...@googlegroups.com
have you tested those commands? do they work?

you can do this:

vagrant halt
VBoxManage list vms

get the id of the Vm you want

VBoxManage showvminfo <id>

see if there is a IDE controller and the correct tname, if not, you
need to create one.

then you can test your command at command line until you get one that works

VBoxManage storageattach 1c4310b6-d5ef-4e79-bc34-ef6dcdb32b69
--storagectl "IDE Controller" --port 1 --device 0 --type dvddrive
--medium none
> --
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vagrant-up+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Vince Skahan

unread,
Jun 19, 2015, 10:59:45 AM6/19/15
to vagra...@googlegroups.com
On Thursday, June 18, 2015 at 7:54:33 PM UTC-7, Alvaro Miranda Aguilera wrote:
have you tested those commands? do they work?


Yes I tested, that's how I got the error transcript showing it did 'not' work.
 

VBoxManage showvminfo <id>

see if there is a IDE controller and the correct tname, if not, you
need to create one.

yeah, that was kind of the question - 'how' do I do that from the commandline and from a Vagrantfile ?

/cygdrive/c/Program\ Files/Oracle/VirtualBox/VBoxManage storageattach bc192c5a-49f8-4db5-98d0-41096c066f40 --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium none

VBoxManage.exe: error: No storage device attached to device slot 0 on port 1 of controller 'IDE Controller'
VBoxManage.exe: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component SessionMachine, interface IMachine, callee IUnknown
VBoxManage.exe: error: Context: "DetachDevice(Bstr(pszCtl).raw(), port, device)" at line 381 of file VBoxManageStorageController.cpp



If there is 'no' CD/DVD device there, I get the following in showvminfo:

Storage Controller Name (0):            IDE Controller
Storage Controller Type (0):            PIIX4
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0):  2
Storage Controller Port Count (0):      2
Storage Controller Bootable (0):        on
IDE Controller (0, 0): C:\Users\vds\VirtualBox VMs\c7-from-upstream_default_1434655611057_90570\vagrant-virtualbox-box.vmdk (UUID: c39ade0e-fc99-43f4-91a1-f9c2cbad7f52)



If I use the gui to manually add the CD/DVD device, showvminfo shows the the following:

Storage Controller Name (0):            IDE Controller
Storage Controller Type (0):            PIIX4
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0):  2
Storage Controller Port Count (0):      2
Storage Controller Bootable (0):        on
IDE Controller (0, 0): C:\Users\vds\VirtualBox VMs\c7-from-upstream_default_1434655611057_90570\vagrant-virtualbox-box.vmdk (UUID: c39ade0e-fc99-43f4-91a1-f9c2cbad7f52)
IDE Controller (0, 1): Empty (ejected)


So how do I add the controller successfully without using the Virtual Box gui ?


If it helps, here's the whole vminfo as-is, with 'no' CD/DVD device defined:

$ /cygdrive/c/Program\ Files/Oracle/VirtualBox/VBoxManage showvminfo c7-from-upstream_default_1434655611057_90570
Name:            c7-from-upstream_default_1434655611057_90570
Groups:          /
Guest OS:        Red Hat (64 bit)
UUID:            bc192c5a-49f8-4db5-98d0-41096c066f40
Config file:     C:\Users\vds\VirtualBox VMs\c7-from-upstream_default_1434655611057_90570\c7-from-upstream_default_1434655611057_90570.vbox
Snapshot folder: C:\Users\vds\VirtualBox VMs\c7-from-upstream_default_1434655611057_90570\Snapshots
Log folder:      C:\Users\vds\VirtualBox VMs\c7-from-upstream_default_1434655611057_90570\Logs
Hardware UUID:   bc192c5a-49f8-4db5-98d0-41096c066f40
Memory size:     1024MB
Page Fusion:     off
VRAM size:       12MB
CPU exec cap:    100%
HPET:            off
Chipset:         piix3
Firmware:        BIOS
Number of CPUs:  1
PAE:             on
Long Mode:       on
Synthetic CPU:   off
CPUID overrides: None
Boot menu mode:  message and menu
Boot Device (1): Floppy
Boot Device (2): DVD
Boot Device (3): HardDisk
Boot Device (4): Not Assigned
ACPI:            on
IOAPIC:          on
Time offset:     0ms
RTC:             UTC
Hardw. virt.ext: on
Nested Paging:   on
Large Pages:     on
VT-x VPID:       on
VT-x unr. exec.: on
State:           powered off (since 2015-06-19T14:44:59.652000000)
Monitor count:   1
3D Acceleration: off
2D Video Acceleration: off
Teleporter Enabled: off
Teleporter Port: 0
Teleporter Address:
Teleporter Password:
Tracing Enabled: off
Allow Tracing to Access VM: off
Tracing Configuration:
Autostart Enabled: off
Autostart Delay: 0
Default Frontend:
Storage Controller Name (0):            IDE Controller
Storage Controller Type (0):            PIIX4
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0):  2
Storage Controller Port Count (0):      2
Storage Controller Bootable (0):        on
IDE Controller (0, 0): C:\Users\vds\VirtualBox VMs\c7-from-upstream_default_1434655611057_90570\vagrant-virtualbox-box.vmdk (UUID: c39ade0e-fc99-43f4-91a1-f9c2cbad7f52)
NIC 1:           MAC: 525400730FB1, Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 1 Settings:  MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64)
NIC 1 Rule(0):   name = ssh, protocol = tcp, host ip = 127.0.0.1, host port = 2222, guest ip = , guest port = 22
NIC 2:           disabled
NIC 3:           disabled
NIC 4:           disabled
NIC 5:           disabled
NIC 6:           disabled
NIC 7:           disabled
NIC 8:           disabled
Pointing Device: PS/2 Mouse
Keyboard Device: PS/2 Keyboard
UART 1:          disabled
UART 2:          disabled
LPT 1:           disabled
LPT 2:           disabled
Audio:           disabled
Clipboard Mode:  disabled
Drag'n'drop Mode: disabled
VRDE:            disabled
USB:             disabled
EHCI:            disabled

USB Device Filters:

<none>

Available remote USB devices:

<none>

Currently Attached USB Devices:

<none>

Bandwidth groups:  <none>

Shared folders:  <none>

VRDE Connection:    not active
Clients so far:     0

Video capturing:    not active
Capture screens:    0
Capture file:       C:\Users\vds\VirtualBox VMs\c7-from-upstream_default_1434655611057_90570\c7-from-upstream_default_1434655611057_90570.webm
Capture dimensions: 1024x768
Capture rate:       512 kbps
Capture FPS:        25

Guest:

Configured memory balloon size:      0 MB


Alvaro Miranda Aguilera

unread,
Jun 19, 2015, 8:18:41 PM6/19/15
to vagra...@googlegroups.com
On Sat, Jun 20, 2015 at 2:59 AM, Vince Skahan <vince...@gmail.com> wrote:
> --port 1 --device 0

Can you test with:

--port 0 --device 1

?

Alvaro Miranda Aguilera

unread,
Jun 19, 2015, 8:34:53 PM6/19/15
to vagra...@googlegroups.com
Hello,

let me do this step by step

I created a hashicorp/precise64 box:

"precise64_default_1434759825291_71417" {480ea0df-8b9b-4884-8864-a9ff072412f7}


VBoxManage showvminfo 480ea0df-8b9b-4884-8864-a9ff072412f7


So in my particular case, we have:

Storage Controller Name (0): IDE Controller

IDE Controller (0, 0): Empty
IDE Controller (1, 0): Empty


Let me add a disk so can match yours:
vagrant-virtualbox-box.vmdk

Create disk:

VBoxManage createhd --filename vagrant-virtualbox-box.vmdk --size 1024
--format VMDK
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100
Disk image created. UUID: 790cc92e-c265-480e-bb8d-e02d53a580ac

Attach the disk to the controller:

VBoxManage storageattach 480ea0df-8b9b-4884-8864-a9ff072412f7
--storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium
vagrant-virtualbox-box.vmdk

Now are similar:

IDE Controller (0, 0):
/Volumes/hd1/Dropbox/vagrant_mini/precise64/vagrant-virtualbox-box.vmdk
(UUID: 790cc92e-c265-480e-bb8d-e02d53a580ac)
IDE Controller (1, 0): Empty

the IDE controller is a dual controller with 2 ports

so we can have 4 devices

let's add a dvd drive to the first controller on the 2nd port

VBoxManage storageattach 480ea0df-8b9b-4884-8864-a9ff072412f7
--storagectl "IDE Controller" --port 1 --device 0 --type dvddrive
--medium emptydrive

IDE Controller (0, 0):
/Volumes/hd1/Dropbox/vagrant_mini/precise64/vagrant-virtualbox-box.vmdk
(UUID: 790cc92e-c265-480e-bb8d-e02d53a580ac)

IDE Controller (1, 0): Empty

ok, so I think I know what happen in your case:


--medium none

medium none is to tell the VirtualBox to delete that dvd

Check:

VBoxManage storageattach 480ea0df-8b9b-4884-8864-a9ff072412f7
--storagectl "IDE Controller" --port 1 --device 0 --type dvddrive
--medium none



IDE Controller (0, 0):
/Volumes/hd1/Dropbox/vagrant_mini/precise64/vagrant-virtualbox-box.vmdk
(UUID: 790cc92e-c265-480e-bb8d-e02d53a580ac)

SATA Controller (0, 0): /Users/alvarom/VirtualBox
VMs/precise64_default_1434759825291_71417/box-disk1.vmdk (UUID:
eee38c7e-cca4-4781-9afd-5f5d57b8cd02)


So, use port 1, device 0, medium emptydrive

Alvaro.

Vince Skahan

unread,
Jun 19, 2015, 11:51:23 PM6/19/15
to vagra...@googlegroups.com
On Friday, June 19, 2015 at 5:34:53 PM UTC-7, Alvaro Miranda Aguilera wrote:
ok, so I think I know what happen in your case:

--medium none

medium none is to tell the VirtualBox to delete that dvd


[...]
 
So, use port 1, device 0, medium emptydrive




aaaahhhh emptydrive.......tried it on VB on the Macbook at home versus that centos/7 base box, and it 'did' work ok from the commandline with vboxmanage  with "vboxmanage storageattach  c7_default_1434771494385_6656 --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium" so I'm thinking positive thoughts re: Windows.

I'll try it on Windows first thing Monday when I get back into work.   Thanks 'much' for your help !

Alvaro Miranda Aguilera

unread,
Jun 20, 2015, 3:24:55 AM6/20/15
to vagra...@googlegroups.com
yeah, i hit the same issue once, and wasn't easy to find in the documentation..

I end googling a lot, and had to read some bugs

if my example looks simple and works because I did it once before so I
was aware of the medium emptydrive vs none

:)

Alvaro.

Vince Skahan

unread,
Jun 22, 2015, 1:56:39 PM6/22/15
to vagra...@googlegroups.com
On Saturday, June 20, 2015 at 12:24:55 AM UTC-7, Alvaro Miranda Aguilera wrote:
yeah, i hit the same issue once, and wasn't easy to find in the documentation..

I end googling a lot, and had to read some bugs

if my example looks simple and works because I did it once before so I
was aware of the medium emptydrive vs none



just to followup - yup worked fine under Windows too.   Thanks again....
 
Reply all
Reply to author
Forward
0 new messages