Home > Tips & tricks > Linux > VirtualBox using physical bootable partition
VirtualBox using physical bootable partition PDF Print E-mail
Written by Administrator   
Sunday, 02 November 2008 22:00

I recently reformated my laptop hardrive to use ArchLinux instead of Gentoo. So I decided to make a special partition to run WinXP natively as well as under virtualbox. I just explain a little the steps I followed to make it working...

 

Partitionning

First, you need to partition your harddrive correctly. That is to say that any bootable partition must be primary.

As a simple example here is my partition scheme for a 160Gb drive:

/dev/sda1 : Primary, /boot (ext2fs, 180 Mb)
/dev/sda2 : Extended Master
/dev/sda3 : Primary, MacOSX (HFS+, 20Gb)
/dev/sda4 : Primary, WinXP (FAT32, 9Gb)
/dev/sda5 : Extended, / (XFS, 20Gb)
/dev/sda6 : Extended, /var (ReiserFS, 9.5Gb)
/dev/sda7 : Extended, /home (XFS, 95Gb)
/dev/sda8 : Extended, Linux swap

As you can see, I use /dev/sda4 as my windows XP partition.

A Virtual disk as partition wrapper

Virtualbox is not able to use physical partition easily out of the box. In fact you have to create a fake disk image that define how to access the physical partition.

Making a pseudo MBR

If you want to make the partition bootable you will need to make a pseudo MBR (Master boot record). The package "ms-sys" contains the tool to build one:

pacman -S ms-sys                                            # install ms-sys package
touch ~/.VirtualBox/WindowsXP.mbr                 # the file that will receive the MBR must exists...
ms-sys --mbr -f ~/.VirtualBox/WindowsXP.mbr   # create a MBR and store it in a file
 

Making the fake disk image

To do so, open terminal and be sure that your user is part of the "vboxusers" and "disk" groups.

Then use VBoxManage (for /dev/sda4):

VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/VDI/winxp_sda4.vmdk \
-rawdisk /dev/sda -partitions 4 -relative -register -mbr ~/.VirtualBox/WindowsXP.mbr

 just after "-filename", you can see the virtual disk file that will represent the VirtualBox disk.
"-rawdisk /dev/sda -partitions 4" is for using /dev/sda4

Using the new partition

Create a new virtual machine and choose the existing harddisk we just created. When the VM wizard has finished, select the VM and edit its setting to turn on "IO APIC".

You can install windows XP either using the VM or booting natively.

As soon as Windows is installed, go to settings / system and open the hardware list windows. find the IDE controller and change the driver to be the "generic IDE".

Then, create a new hardware profile. You can reboot the computer or th VM. You will now have to choose the profile to use before booting.

Now you can install all needed drivers for each profile, but do not try to boot VirtualBox with the profile used for the hardware boot, else it wont work (and vice-versa).

Last Updated on Sunday, 02 November 2008 22:56
 
Comments (7)
7 Friday, 08 May 2009 13:24
webmaster
nelso: no I nerver tried that. I wonder if MacOS X has an hardware profile handler like windows as MacOS is, in general, dedicated to one hardware...
6 Sunday, 26 April 2009 21:43
nelso
Have you tried to boot the mac osx partition from virtualbox?
5 Monday, 16 February 2009 21:24
coCoKNIght
Thanks, yeah I found out about that, first I used bootcfg from the Windows CD 'reapair' dos (via VirtualBox). It told me that there is no entry so it made a new entry in boot.ini
I rebooted my machine and chose to start from the newly created aditional boot.ini entry. The Windows logo with the loading bar apears for a brief moment, then I get a bluescreen for a brief moment and my laptop restarts. Windows starts normally from vBox though. I have tried to reinstall Win, but same problem. Maybe I should try by formating the partition with linux first and then reinstall, but I don't think it'll be successful.
4 Monday, 16 February 2009 10:43
webmaster
coCoKNIght: The problem may come from the boot.ini file. It probably contains a bad partition or disk number so the hall.dll is not found. This is certainly due to the fact that the virtual machine does not show the same partition / disk number has the real machine's bios.

If you can gain access to the boot.ini file, check sections [boot loader]
and [operating systems], then try to change disk and/or partition number
3 Friday, 13 February 2009 16:05
coCoKNIght
For me the main advantage is that I can actually install Windows on my HP Mini that doesn't have a CD-drive...
However, using this method, when the installer restarts the first time windows won't boot saying that \system32\hal.dll is missing or damaged.
Any ideas?
2 Thursday, 27 November 2008 21:53
webmaster
The main advantage I see is that you have only one windows configuration that is the same when you use Virtualbox or when you boot directly to windows.

In terms of speed; it is probably faster that a classical Harddive file because we use a true partition here.

And finaly yes you can use seamless mode. In fact you can use all virtualbox features.
1 Saturday, 15 November 2008 10:11
mizar
What is the advantage of this e.g. more speed? Is it still possible to use virtualbox in seamless mode and file sharing with the above method?

Add your comment

Your name:
Your email:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification:
 
Original design by i-cons.ch / namibia-forum.ch