9 Advanced topics
arbitrary ways without having to recreate the image file that gives access to the raw
disk.
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), on a Linux
host, use the command
VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk
-rawdisk /dev/sda
This creates the image
/path/to/file.vmdk
(must be absolute), and all data will
be read and written from
/dev/sda
.
On a Windows host, instead of the above device specification, use e.g.
\\.\PhysicalDrive0
.
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.
Just like with regular disk images, this does not automatically register the newly cre-
ated image in the internal registry of hard disks. If you want this done automatically,
add
-register
:
VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk
-rawdisk /dev/sda -register
After registering, you can assign the newly created image to a virtual machine with
VBoxManage modifyvm WindowsXP -hda /path/to/file.vmdk
When this is done the selected virtual machine will boot from the specified physical
disk.
9.10.2 Access to individual physical hard disk partitions
This “raw partition support” is quite similar to the “full hard disk” access described
above. However, in this case, any partitioning information will be stored inside the
VMDK image, so you can e.g. install a different boot loader in the virtual hard disk
without affecting the host’s partitioning information. While the guest will be able to
see
all partitions that exist on the physical disk, access will be filtered in that reading
from partitions for which no access is allowed the partitions will only yield zeroes, and
all writes to them are ignored.
To create a special image for raw partition support (which will contain a small
amount of data, as already mentioned), on a Linux host, use the command
VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk
-rawdisk /dev/sda -partitions 1,5
As you can see, the command is identical to the one for “full hard disk” access,
except for the additional
-partitions
parameter. This example would create the
image
/path/to/file.vmdk
(which, again, must be absolute), and partitions 1
and 5 of
/dev/sda
would be made accessible to the guest.
136