Attach physical disk to a virtual box VM

From Wiki
Revision as of 00:53, 13 September 2020 by Admin (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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:

http://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html

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

On windows you will need to use the physical disk number shown in disk management.

VBoxManage.exe internalcommands createrawvmdk -filename c:\compaq.vmdk -rawdisk \\.\PhysicalDrive1

Windows also requires using the host I/O cache to avoid errors.

->Virtual Box settings ->Storage ->Controller:SATA (Check the option "Use Host I/O Cache")

As 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 http://www.virtualbox.org/manual/ch09.html#idp13208480 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 10.20.34.127 --target iqn.2001-05.com.equallogic:0-8a0906-b990cd108-a42000000d152a8a-wattersm-test --username username --password password --port 0 --device 0 --type hdd