While this variant is the simplest to set up, you must be aware that this will give a guest operating system direct and full access to an entire physical disk. If your host operating system is also booted from this disk, please take special care to not access the partition from the guest at all. On the positive side, the physical disk can be repartitioned in arbitrary ways without having to recreate the image file that gives access to the raw disk.
On a Linux host, to create an image that represents an entire physical hard disk which will not contain any actual data, as this will all be stored on the physical disk, use the following command:
$ VBoxManage createmedium disk --filenamepath-to-file .vmdk --format=VMDK --variant RawDisk --property RawDrive=/dev/sda
This creates the
On a Windows host, instead of the above device specification,
for example use
Creating the image requires read/write access for the given device. Read/write access is also later needed when using the image from a virtual machine. On some host platforms, such as Windows, raw disk access may be restricted and not permitted by the host OS in some situations.
Just like with regular disk images, this does not automatically attach the newly created image to a virtual machine. This can be done as follows:
$ VBoxManage storageattach WindowsXP --storagectl "IDE Controller" \ --port 0 --device 0 --type hdd --mediumpath-to-file .vmdk
When this is done the selected virtual machine will boot from the specified physical disk.