Running a VirtualBox Guest from a Real Partition

This guide covers running an installed OS from an actual partition as a guest OS inside of VirtualBox.

= Create a VirtualBox VMDK = A VMDK (Virtual Machine Disk) file is a file that points to an actual partition, as compared to a VDI file which actually houses a (virtual) disk's contents.

Note: If you have a boot partition (for GRUB or LILO, for example) and your guest OS is Linux it can be convenient to make sure your VMDK includes this partition.

Get partition information in Linux
First, find the drive and partition(s) you want to run virtualized. In a terminal, type sudo VBoxManage internalcommands listpartitions -rawdisk /dev/sda where sda is your drive's device node. It will follow the format sdX or hdX. fdisk -l is a good way of listing your attached devices.

Take note of the device notes and partition numbers you want. If you want VirtualBox to be aware of all partitions you don't need to take note of partition numbers.

Get partition information in Windows
In a Windows Command Prompt (as administrator), type C:\Program Files\Sun\VirtualBox>VBoxManage internalcommands listpartitions -rawdisk \\.\PhysicalDrive0 where 0 represents your first hard drive, 1 your second, and so forth.

Take note of the drive number and partition numbers you want. If you want all partitions you just need to take note of the drive number.

Create VMDK in Linux
$ sudo VBoxManage internalcommands createrawvmdk -filename myos.vmdk -rawdisk /dev/sda -partitions 1,3,4

Create VMDK in Windows
C:\Program Files\Sun\VirtualBox>VBoxManage internalcommands createrawvmdk -filename myos.vmdk -rawdisk \\.\PhysicalDrive0 -partitions 1,2

= Create the virtual machine =

You may have to fix up user, file and disk permissions - mostly I've seen sudo chmod 666 *.vmdk.

Or alternatively, in Linux, just run Virtualbox as root (in the example I'm saying to run it as a background process):

$ sudo VirtualBox &

= Prepare the guest OS for virtualization =

Prepare Windows for virtualization
= Boot the virtual machine =

= See Also =