Quick reference for adding and attaching drives in VirtualBox CLI

Recently VirtualBox Manager GUI running on my Windows box, began to crash without any known reason when creating new or attaching existent virtual drives to any of the virtual machines. So I have to do all the things using CLI now and definitely I enjoy the time.

Create a new drive


VBoxManage createmedium [disk|dvd|floppy] --filename
[--size |--sizebyte ]
[--diffparent |
[--format VDI|VMDK|VHD] (default: VDI)
[--variant Standard,Fixed,Split2G,Stream,ESX]

Usage example

Create a new 256MB fixed sized drive d02.vdi:

VBoxManage createmedium disk --filename "D:\VirtualBox VMs\vdrives\d02.vdi" --size 256 --format VDI --variant Fixed

Attach the drive to a controller


VBoxManage storageattach <uuid|vmname>
[--port ]
[--device ]
[--type dvddrive|hdd|fdd]
[--medium none|emptydrive|additions|
[--mtype normal|writethrough|immutable|shareable|
[--comment ]
[--setuuid ]
[--setparentuuid ]
[--passthrough on|off]
[--tempeject on|off]
[--nonrotational on|off]
[--discard on|off]
[--hotpluggable on|off]
[--bandwidthgroup ]
[--server |]
[--target ]
[--tport ]
[--lun ]
[--encodedlun ]
[--username ]
[--password ]
[--initiator ]

Usage example

Attaching already created d02.vdi virtual HDD to the SAS-controller port 3 of myvhost virtual machine:

VboxManage storageattach myvhost --storagectl SAS --port 3 --type hdd --medium "D:\VirtualBox VMs\vdrives\d02.vdi"


About mezzantrop

12+ years of experience in large SAN and storage environments: mainly Hitachi, HP and Brocade. Now I am a proud SAN/storage IBMer. Redbooks author. The BeaST – storage-system concept inventor. Empty – expect-like tool developer. FreeBSD enthusiast.
This entry was posted in Storage, Tips & tricks and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.