Sunday, 4 September 2011

How to virtualize raw Linux partition inside Windows 7 with VirtualBox

To virtualize an existing linux install (Ubuntu 10.10 32-bit in my case) under Windows 7 64-bit, follow these steps:
(Most of the information here is listed in the VirtualBox help file)

  1. Install Windows 7 and Linux
  2. Install VirtualBox
  3. Open an elevated command prompt (=> rightclick command.exe and run as administrator).
  4. Browse to where virtualbox is installed (cd Program Files\Oracle\VirtualBox)
  5. Enter the following command:

    VboxManage internalcommands listpartitions -rawdisk \\.\PhysicalDrive0

    This will list the available partitions for the selected Drive. Drive0 or the first hard drive, 1 for the second hard drive etc... so you can decide which partition to take. Find the number of the partition linux is installed on.
  6. Create a .vmdk file by entering the following command:

    VboxManage internalcommands createrawvmdk -filename linux.vmdk -rawdisk \\.\PhysicalDrive0 -partitions 3

    This will create a file called linux.vmdk for disk0, partition 3, which contains information about the partition and is needed to virtualize this partition.
  7. Make sure to run VirtualBox as administrator (it won't work otherwise!!) and create a new virtual machine and load the the linux.vmdk file.
  8. Make sure to select your linux OS in Grub, especially if you have Windows as your standard OS to boot.
Some problems with this:
  • VirtualBox virtualizes the whole disk, not just the partition. With the createrawvmdk command a linux-pt.vmdk file is created, which I think contains information about the virtualized partition, but I am unable to load it in VirtualBox.
  • I am stuck at a resolution of 800x640 in Ubuntu, I have had no luck correctly installing the Guest additions.
  • Loading Windows 7 when booting the virtual disk is potentially harmful from what I read on forums.

Anyway, it works well enough for quick access to your other OS from Windows 7, but I don't find it too useful to actually work in. And the fact that it might cause serious damage to your installations, prevents me from actually using it.

For more information, see the help files in VirtualBox for 'Advanced storage configuration'. I will update this post if I find out more!

No comments:

Post a Comment