24

There used to be a VirtualBox command with this syntax:

VBoxManage controlvm <VM> dvdattach <filename>

So attaching (inserting) a CD/DVD was as easy as:

VBoxManage controlvm "MyVM Windows 7" dvdattach MyDVD.iso

But now this command has disappeared.

I searched in the VirtualBox Manual and found the storageattach command which has a reference to storagectl. Unfortunately, those manual sections lack examples, and neither one mentions .ISO files. I also looked through the VirtualBox forum, but couldn't find a solution that worked for me. The closest I found said this:

Once you have the controller in place with storagectl (or via the GUI), take a look at VBoxManage storageattach

I am not sure what to do. How can I mount an ISO to a VirtualBox VM in a newer version without the controlvm ... dvdattach syntax?

2 Answers 2

28

Manage the IDE controller

In case the VM doesn't have an IDE controller you can use the storagectl command to add one:

VBoxManage.exe storagectl "<uuid|vmname>" --name IDE --add ide

Attach a disk image file

Here's a sample syntax you can use to attach a CD/DVD image file:

VBoxManage.exe storageattach "<uuid|vmname>" --storagectl IDE --port 0 --device 0 --type dvddrive --medium "X:\Folder\containing\the.iso"

Detach a disk image file

To detach an image file the syntax is similar: you just need to replace the file path with "none". The --type parameter can be omitted:

VBoxManage.exe storageattach "<uuid|vmname>" --storagectl IDE --port 0 --device 0 --medium "none"

Further reading

9
  • 3
    Also, all relevant information on a virtual machine can be discovered with VBoxManage showvminfo. This includes storage controllers and their names.
    – Daniel B
    Apr 14, 2014 at 22:21
  • 1
    @DanielB, VBoxManage showvminfo lists IDE (1, 0): C:\Oracle\VirtualBox\VBoxGuestAdditions.iso and SATA (0, 0): d:\VirtualBox VMs\Windows 7 SP1 - SandBox 01\Win7SP1.vmdk . I am a bit confused about both 0 and 1. Do they correlate with --port and --device? Apr 14, 2014 at 22:56
  • When concerning ISO image files, should I add an ide or a sata device? Apr 14, 2014 at 23:01
  • @SopalajodeArrierez Yes, those numbers are port/device identifiers. For maximum compatibility you should pick an IDE controller for virtual CD/DVD drives: "So even if your guest operating system has no support for SCSI or SATA devices, it should always be able to see [it]." Other than that, VirtualBox gives you "four slots attached to the traditional IDE controller, which are always present" and "30 slots attached to the SATA controller, if enabled and supported by the guest operating system." Source
    – and31415
    Apr 14, 2014 at 23:17
  • IDE controllers have two ports (the first item in the tuple), each capable of connecting two devices (the second element). Same as on a real PC. The GUI attaches optical media to (1, 0) by default.
    – Daniel B
    Apr 15, 2014 at 6:47
14

First of all, check if you have any CD/DVD drive installed, whether empty or not (note the use of the find command to filter results):

1.- Is there any empty CD/DVD drive?

C:\Oracle\VirtualBox>vboxmanage showvminfo "Windows 7 SP1 - SandBox 01" | find "empty" /i
SATA (1, 0): Empty

Congratulations, you have found a possible empty CD/DVD drive. So you can attach your ISO to it, but...

... in order to face the worst scenario, lets show another way to find your CD/DVD drive, if installed:

2.- Locate the name of your VM:

C:\Oracle\VirtualBox>VBoxManage.exe list vms
"Windows 7 SP1 - SandBox 01" {e016fcf2-9b6e-4b8e-b89b-49a3c8ba0898}

3.- List its storage controllers (note the find command to filter too much output data) (*):

C:\Oracle\VirtualBox>vboxmanage showvminfo "Windows 7 SP1 - SandBox 01" | find "storage controller name" /i
Storage Controller Name (0):            IDE
Storage Controller Name (1):            SATA

4.- Show its attached devices:

C:\Oracle\VirtualBox>vboxmanage showvminfo "Windows 7 SP1 - SandBox 01" | find "IDE"
Storage Controller Name (0):            IDE

(this one is empty, so there are no device controllers, whether hard disks or CD/DVD drives)

C:\Oracle\VirtualBox>vboxmanage showvminfo "Windows 7 SP1 - SandBox 01" | find "SATA"
Storage Controller Name (1):            SATA
SATA (0, 0): d:\VirtualBox VMs\Windows 7 SP1 - SandBox 01\SnapShots/{71b8bf72-dca1-4816-89ff-feba271ec262}.vmdk (UUID: 71b8bf72-dca1-4816-89ff-feba271ec262)
SATA (1, 0): Empty

SATA(0,0) has a(the) virtual disk, and SATA(1,0) is empty (first number between parentheses is known as type, second one is device), so it should be the CD/DVD drive.

5.- Lets attach an ISO image file (Office 2013, for example) to it:

C:\Oracle\VirtualBox>vboxmanage storageattach "Windows 7 SP1 - SandBox 01" --storagectl "SATA" --port 1 --device 0 --type dvddrive --medium "Office2013-VL-SP1.iso"

(no results on screen means OK).

$- To remove the ISO keeping the CD/DVD drive controller:

C:\Oracle\VirtualBox>vboxmanage storageattach "Windows 7 SP1 - SandBox 01" --storagectl "SATA" --port 1 --device 0 --type dvddrive --medium "emptydrive"

$- For the case there is no "empty" CD/DVD drive controller installed, VirtualBox should add a new one to an existing controller, assumed we choose a not-occupied port/device, for example for the SATA controller:

C:\Oracle\VirtualBox>vboxmanage storageattach "Windows 7 SP1 - SandBox 01" --storagectl "SATA" --port 5 --device 0 --type dvddrive --medium "Office2013-VL-SP1.iso"

(note we used port 5)
And for the IDE controller:

C:\Oracle\VirtualBox>vboxmanage storageattach "Windows 7 SP1 - SandBox 01" --storagectl "IDE" --port 0 --device 0 --type dvddrive --medium "Office2013-VL-SP1.iso"

(note we used (0,0), this is, the first port and first device)

$- If we want to remove (destroy) (any of) the devices (example for the last IDE one):

C:\Oracle\VirtualBox>vboxmanage storageattach "Windows 7 SP1 - SandBox 01" --storagectl "IDE" --port 0 --device 0 --type dvddrive --medium "emptydrive"

(the ISO image gets umounted at the same time of executing this command).

$- Finally, if we wanna create a new controller instead of using the existing(s) one(s) (example for a SATA controller that we will name SATA3):

C:\Oracle\VirtualBox>vboxmanage storagectl "Windows 7 SP1 - SandBox 01" --name SATA3 --add sata

$- And maybe removing it later:

C:\Oracle\VirtualBox>vboxmanage storagectl "Windows 7 SP1 - SandBox 01" --name SATA3 --remove

(*) If the name is not enough (could have been changed) to figure out what kind of controller is it, try:

C:\Oracle\VirtualBox>vboxmanage showvminfo "Windows 7 SP1 - SandBox 01" | find "storage controller" /i
Storage Controller Name (0):            IDE
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
Storage Controller Name (1):            SATA
Storage Controller Type (1):            IntelAhci
Storage Controller Instance Number (1): 0
Storage Controller Max Port Count (1):  30
Storage Controller Port Count (1):      2

As we can see, controller named IDE (#0) is a PIIX4 device (IDE) and the one named SATA (#1) is an IntelAhci (SATA).

NOTE: IDE controllers accept possible image files at 4 configurations: (0,0), (0,1), (1,0) and (1,1). Choose the one that is not occupied. SATA controllers accept 30. These parameters can be configured on VM properties. Remember that, in both cases, count starts at 0, not 1.

NOTE2: Some devices can be created during VM execution (running), depending on the operating system and device. For example, SATA devices can be created on runtime for Windows 7 VMs. Anyway, an ISO CD/DVD image file can always be inserted on runtime in any empty medium. You can check running vms by doing:

C:\Oracle\VirtualBox>vboxmanage list runningvms

Thanks to @and31415 and @DanielB for their comments and info.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .