If the same virtual machines should be used on a multi boot system there are at least 3 choices:
- A fat32 partition with virtual disk files. But disk size is limited to 4GB.
- An iSCSI disk connected by network. Speed is limited by network throughput.
- Direct access to hard disk partitions used as virtual disks. With windows a separate hard disk has to be used.
The third choice is described below. Thus a second hard disk only used with virtual machines is required. To allow hard disks with more than 2 TB capacity the disk is partitioned as gpt disk.
Warning: the commands described below can erase the whole data of your hard disks if a mistake is made. Do not continue unless you have a full backup of your system.
========================================
(Yes I am prepared to restore my system in case of a mistake …):
Attach an additional hard disk to your computer which is only used for virtual box images (tested with internal disk; should work with usb disk).
(At least the currently running (host) operating system must not be installed on the same disk).
Add a new partition to the additional hard disk. (If the new virtual disk has 25 GB then the size of the new partion is 25 GB.) In case of a gpt partioned disk up to 128 partitions can be created.
- with a linux host using gdisk the type of the new partition can be set to 0x8301 (linux reserved)
(internally translated by gdisk to 8DA63339-0007-60C0-C436-083AC8230908)
In case of windows 7 as virtual machine the hardware uuid of the vm must be the same
in the three hosts (linux, osx, windows). (Else the activation of windows 7 cannot be kept.)
- to display the hardware uuid of the activated vm (with name W7) use:
VBOxManage showvminfo W7 |grep Hardware - to set the hardware uuid of a vm (with name W7_1) use the uuid displayed by showvminfo:
VBoxManage modifyvm W7_1 –hardwareuuid 12345678-1234-abcd-0123-0123456789ab
Using this partition as virtual hard disk with a linux host:
- determine the device name of the new partition, e.g. /dev/sdb7
(cat /proc/partitions, gdisk -l /dev/sdb …) - either ad the current user to group disk to allow raw access to all disks
(has only to be done once; is effective after re-login; but is potentially dangerous).
Or change the group of /dev/sdb7 to vboxusers
(to be repeated after reboot) - run as root user:
VBoxManage internalcommands createrawvmdk -rawdisk /dev/sdb7 -filename my_filename.vmdk
and change the ownership of this file to the current user - run VirtualBox and add my_filename.vmdk as hard disk to the virtual machine
Using this partition as virtual hard disk with a OS X host:
- determine the device name of the new partition, e.g. /dev/disk1s7
(ls -l /dev/disk* …) - ad the current user to group operator to allow raw access to all disks
(is effective after re-login; is potentially dangerous):
dseditgroup -o edit -a name_of_current_user -t user operator - Change permission of group from read access to write access
sudo chmod g+w /dev/disk1s7
(to be repeated after reboot) - run as root user:
VBoxManage internalcommands createrawvmdk -rawdisk /dev/disk1s7 -filename my_filename.vmdk
and change the ownership of this file to the current user - run VirtualBox and add my_filename.vmdk as hard disk to the virtual machine
- if OS X auto mounts partitions which should be used by virtualbox: try to deactivate them with disk utility; in case that does not work you can run disk arbitrator which blocks auto mount
Using this partition as virtual hard disk with a Windows 8 64 bit host:
- requires to run VirtualBox with administrative privileges
- determine the device name of the new partition, e.g. diskpart
list disk
select disk 1
list partition
select partition 7
detail partition - windows blocks raw access to the hard disk if the disk is online; use diskpart to switch the disk offline:
list disk
select disk 1
offline disk - if the disk is mbr partioned open a console window with administrative privileges and run:
“C:\Program Files\Oracle\VirtualBox\VBoxManage internalcommands createrawvmdk -rawdisk \\.\PhysicalDrive1 -filename my_filename.vmdk -partitions 7
if the disk is a gpt disk VBoxManage will crash (with VirtualBox 4.2.12) and you have to run this command using a linux host
VBoxManage internalcommands createrawvmdk -rawdisk /dev/sdb -filename my_filename.vmdk -partitions 7
(the resulting file my_filename.vmdk hast to be copied to the windows host) - use wordpad to edit the vmdk file, so that partition 7 is seen as a whole virtual disk:
(once again a warning: an editing mistake might erase all data of your hard disks)
change createType to “fullDevice”
between the lines “# Extent description” and “# The disk Data Base”
delete all lines except the one refering to partition 7 (e.g. RW 52428800 FLAT “\\.\PhysicalDrive1” 482756608)
If the vmdk file has been created with linux then the linux device name (e.g. /dev/sdb) has to be replaced
by the windows device name (e.g. \\.\PhysicalDrive1) - run VirtualBoxwith administrative privileges and add my_filename.vmdk as hard disk to the virtual machine
Leave a Reply