Some virtualization systems have recently been able to handle real hard disk partitions. This is specially useful if you have a dual boot system (lets say Windows and Linux) but you frequently have to access a system while running the other. Then the solution is to use a virtual machine with your real OS installation.
In my case I'm accessing Linux from my Windows XP installation using VirtualBox. For the other way round you can easily find several how-to's around.
The most important and not obvious step is how to create the mapping virtual disk.
First you'll need to have the boot sector of your Linux Machine accessible. To create it use dd to extract the first 512 bytes from your bootable Linux partition. (In this case I have grub installed on it, NOT in the MBR).
After, please find the VirtualBox name of your partition.
- VBoxManage.exe internalcommands listpartitions -rawdisk \\.\PhysicalDrive0
Switch PhysicalDrive0 to PhysicalDrive1, PhysicalDrive2... as needed.
You should see something like this:
Number Type StartCHS EndCHS Size (MiB) Start (Sect)
1 0x07 0 /32 /33 13 /163/19 100 2048
2 0x07 13 /163/20 1023/239/63 20480 206848
3 0x07 1023/239/63 1023/239/63 26410 42149888
4 0x83 1023/239/63 1023/239/63 10239 96238800
To create the VirtualBox disk issue the command:
- VBoxManage.exe internalcommands createrawvmdk -filename e:\vm\ubunturaw.vmdk -rawdisk \\.\PhysicalDrive0 -register -partitions 4 -mbr c:\linux.bin
-filename is the VirtualDisk name (may include path)
-register tells VirtualBox to register the virtual disk in the Virtual Media Manager
-partitions specifies which partition is to be mapped. Make sure it's your linux partition. If you don't specify VirtualBox will try to map the whole Disk, which can corrupt your data, besides not accepting your mbr file.
-mbr Specifies the master boot record for your system (required)
Now just create a common virtual machine with the recently created disk!