Friday, 14 May 2010

Physical Disk Access On VirtualBox Guest

See my previous post regarding using Virtualbox on a headless system here.

In vmware-server, mapping a drive to a physical disk is easy.

To do this in virtualbox it is ugly and hackish. The simple solution as described in the manual and repeated all over the interwebs is to use this command;

VBoxManage internalcommands createrawvmdk -filename physicaldisk.vmdk -rawdisk /dev/sdd -register

Unfortunately, this produces "VERR_ACCESS_DENIED" errors amongst other things.

Well, that's OK you might think, in vmware you need to give your user write access to the physical disk by adding it to the "disks" group. Logout, login, try again, same result.


Here is what you have to do;

Run the command as root
sudo VBoxManage internalcommands createrawvmdk -filename physicaldisk.vmdk -rawdisk /dev/sdd -register

Ignore the nasty error
RAW host disk access VMDK file 2TbExt.vmdk created successfully.
ERROR: Could not find file for the medium '/root/.VirtualBox/HardDisks/2TbExt.vmdk' (VERR_FILE_NOT_FOUND)

Change the ownership back to your user
sudo chown brettg:brettg physicaldisk.vmdk

Apply full permissions to all on the physical drive
sudo chmod 777 /dev/sdd*

Attach it to your guest
VBoxManage storageattach ganymede --storagectl IDE0 --port 1 --device 0 --type hdd --medium ~/.VirtualBox/Machines/ganymede/2TbExt.vmdk

It's not pretty or nice, pretty nasty in fact but it works. It's hasn't done much to convince me to stick with VirtualBox over the long haul though.

No comments: