让virtualbox支持U盘启动#进入命令行 参考资料: 9.9. Using a raw host hard disk from a guest With VirtualBox, this type of access is called "raw hard disk access"; it allows a guest operating system to access its virtual hard disk without going through the host OS file system. The actual performance difference for image files vs. raw disk varies greatly depending on the overhead of the host filesystem, whether dynamically growing images are used and on host OS caching strategies. The caching indirectly also affects other aspects such as failure behavior, i.e. whether the virtual disk contains all data written before a host OS crash. Consult your host OS documentation for details on this. Warning Raw hard disk access -- both for entire disks and individual partitions -- is implemented as part of the VMDK image format support (see Section 5.4, “VMDK image files”). As a result, you will need to create a special VMDK image file which defines where the data will be stored. After creating such a special VMDK image, you can use it like a regular virtual disk image. For example, you can use the Virtual Disk Manager (Section 3.5, “The Virtual Disk Manager”) or VBoxManage to assign the image to a virtual machine. 9.9.1. Access to entire physical hard 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 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 created image in the internal registry of hard disks. If you want this done automatically, add -register: VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk VBoxManage modifyvm WindowsXP -hda /path/to/file.vmdk 9.9.2. Access to individual physical hard disk partitions 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 VirtualBox uses the same partition numbering as your Linux host. As a result, the numbers given in the above example would refer to the first primary partition and the first logical drive in the extended partition, respectively. On a Windows host, instead of the above device specification, use e.g. \\.\PhysicalDrive0. Partition numbers are the same on Linux and Windows hosts. The numbers for the list of partitions can be taken from the output of VBoxManage internalcommands listpartitions -rawdisk /dev/sda 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 internalcommands createrawvmdk -filename /path/to/file.vmdk In some configurations it may be necessary to change the MBR code of the created image, e.g. to replace the Linux boot loader that is used on the host by another boot loader. This allows e.g. the guest to boot directly to Windows, while the host boots Linux from the "same" disk. For this purpose the -mbr parameter is provided. It specifies a file name from which to take the MBR code. The partition table is not modified at all, so a MBR file from a system with totally different partitioning can be used. An example of this is VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk For each of the above variants, you can register the resulting image for immediate use in VirtualBox by adding -register to the respective command line. The image will then immediately appear in the list of registered disk images. An example is VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk |
|