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

Syntax

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

Syntax

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

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"

Advertisements

About mezzantrop

10 years of experience in large SAN and storage environments: mainly Hitachi, HP and Brocade. Now I am a proud SAN/storage IBMer. Empty – expect-like tool author. 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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s