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. This means that you can 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, on a Linux host, use the command:
$ VBoxManage createmedium disk --filenamepath-to-file .vmdk --format=VMDK --variant RawDisk --property RawDrive=/dev/sda --property Partitions=1,5
The command is identical to the one for full hard disk access,
except for the additional
On a Windows host, instead of the above device specification,
use for example
The numbers for the list of partitions can be taken from the output of the following command:
$ VBoxManage list hostdrives
The output lists available drives and their partitions with the partition types and sizes to give the user enough information to identify the partitions necessary for the guest.
Images which give access to individual partitions are specific to a particular host disk setup. You cannot transfer these images to another host. Also, whenever the host partitioning changes, the image must be recreated.
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. If this is not feasible, there is a special variant for raw partition access, currently only available on Linux hosts, that avoids having to give the current user access to the entire disk. To set up such an image, use:
$ VBoxManage createmedium disk --filenamepath-to-file .vmdk --format=VMDK --variant RawDisk --property RawDrive=/dev/sda --property Partitions=1,5 --property Relative=1
When used from a virtual machine, the image will then refer
not to the entire disk, but only to the individual partitions.
In this example,
In some configurations it may be necessary to change the MBR
code of the created image. For example, to replace the Linux
boot loader that is used on the host by another boot loader.
This enables for example the guest to boot directly to
Windows, while the host boots Linux from the "same" disk. For
this purpose the
$ VBoxManage createmedium disk --filenamepath-to-file .vmdk --format=VMDK --variant RawDisk --property RawDrive=/dev/sda --property Partitions=1,5 --property-file BootSector=winxp.mbr
The modified MBR will be stored inside the image, not on the host disk.
The created image can be attached to a storage controller in a VM configuration as usual.