Virtualbox and raw host disk access
The setup used in this article is an Ubuntu 12.04 host system with VirtualBox 4.1.18 installed.
/dev/sda the partitions 3 and 4 will be made available to a virtual machine. All virtual machines
are run as user
virtualbox. All console samples show clearly the user that runs the command.
On Ubuntu, raw devices have the following default access rights:
To give the
virtualbox user proper access to the disks, the
disk group will be extended:
Before going any further, please make sure that any processes currently running as user virtualbox
This is needed for these processes to pick up the changed permissions. Next to the VirtualBox subsystems,
don’t forget to restart the active shell sessions. By adding the
virtualbox user to the group
the change is also persisted over system reboots.
With the proper access in place, we first create the VMDK file pointing to the raw device:
Assuming that the VM
machine1 is already created and contains a storage controller, the raw disk is now
attached to the virtual machine:
On successful completion, this command returns no output. If you want to validate that the disk is attached correctly, print the virtual machine information:
Please report typos and/or improvements to this article in the comments!