Attach physical disk to a virtual box VM

From Wiki
Jump to: navigation, search

Virtual Box does support attaching physical (raw) drives to a VM but there is no option for it in the GUI. To attach a drive to a VM you will first need to install the Oracle VM VirtualBox Extension Pack available here:

After that is done you can create and attach a new virtual disk from the command line.

VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk
     -rawdisk /dev/sdf

This creates the image /path/to/file.vmdk (must be absolute), and all data will be read and written from /dev/sdf.

Just like with regular disk images, this does not automatically attach the newly created image to a virtual machine. This can be done with e.g.

VBoxManage storageattach <NAME> --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium /path/to/file.vmdk

See for more details.

Change UUID of a disk:

VBoxManage internalcommands sethduuid disk_image.vdi

Attach iSCSI target:

VBoxManage storageattach <vm> --storagectl IDE --medium iscsi --server --target --username username --password password --port 0 --device 0 --type hdd