I have managed to successfully boot my Windows XP raw partition from within Linux (Ubuntu, Karmic Koala Alpha 4) using Sun’s Virtual Box so I thought I’d share my successes and gotchas with you.
Warnings and expectations!
I accept no responsibility for the loss or damage to your data or computer by following these instructions!
First up – these instructions worked for me and were collated from lots of googling and sanitising other instructions found on the internet. I’m hoping these are a little more straightforward to follow than some I’ve seen.
Secondly, although I got this going, it wasn’t necessarily the ideal set up I was hoping for. The computer I was using for this was an Compaq NC6400 with 4Gb Ram and a very slow hard drive. There are no hardware virtualisation features on my model so although it was cool to get it working, the speed of disk access was nearly enough to see me go mad.
My hard drive disk layout was your pretty average Windows XP partition followed by some Linux partitions:
Disk /dev/sda: 60.0 GB, 60022480896 bytes
255 heads, 63 sectors/track, 7297 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x7e987e98
Device Boot Start End Blocks Id System
/dev/sda1 * 1 5338 42877453+ 7 HPFS/NTFS
/dev/sda2 5339 5363 200812+ 83 Linux
/dev/sda3 5364 5736 2996122+ 82 Linux swap / Solaris
/dev/sda4 5737 7297 12538732+ 83 Linux
Pre-Requisite – Windows XP Preparation
There are a couple of things that need to be done under Windows XP prior to starting this. This includes running the MergeIDE utility which preps a system to be moved to another piece of hardware (in our case, a virtual machine) as Windows XP isn’t so friendly when it comes across different hardware. Also you need to create hardware profiles – you will be booting your original Windows XP that has been running under your specific hardware, and not Virtual Box’s virtual hardware.
- Download, extract and run the MergeIDE utility from this site
- Create a hardware profile under Windows XPRight Click on My Computer and go to Properties, then click on the Hardware tab. From there you can create new hardware profiles which you can select on boot.
Virtual Box and Windows XP raw partition
Sun’s VBox can be downloaded from Sun’s Virtual Box Website or by using your Linux distribution’s software installer. As I was running Ubuntu the instructions will be specific to that.
- Ensure your user is a member of the ‘disk’ group as your normal unprivileged user needs access to the partitions that Linux can seesudo usermod -a -G disk username
You will need to log out and log back in again for the whole X desktop (e.g. Gnome) session to see the changes.
- sudo aptitude install virtualbox-ose mbrmbr package provides a means of creating a new boot record that will be used to boot your partition
the virtualbox-ose package is the Open Source Edition as packaged up by Ubuntu
- mkdir -p ~/.VirtualBox&&cd ~/.VirtualBox
- install mbr –force MBR.mbrthis creates a new master boot record for you to use to boot your partition
- Refer to the disk partitioning layout and recall in the example above that /dev/sda, partition 1 (/dev/sda1) has my Windows XP install. Also note that /dev/sda has my original MBR so we will need to directly reference partition 1 to get access to Windows XP directly.Check your disk layout by doing the following
fdisk -l /dev/sda
Note normally you’d expect to prepend that with sudo (or be root) to view this, but this is a good check that your permissions are working as expected. If not – check you have set up your user permissions correctly and have logged out and back in again.
Still not working after that? Do an ls -l /dev/sda and check the group that has write permissions on the partition. Add your username to that.
- IMPORTANT – UNMOUNT THE WINDOWS PARTITION FROM LINUXYou don’t want to have multiple OSes accessing the same device simultaneously. You have been warned!
- Create the disk file that VBox will use to access the partition:VBoxManage internalcommands createrawvmdk -filename ./WindowsXP.vmdk -rawdisk /dev/sda -partitions 1 -mbr ./MBR.mbr -relative -register
This says create a file called WindowsXP.vmdk in the current dir, the disk is /dev/sda and the partition number is 1. We’re using the MBR file created in step number 4. The register option adds this into the Virtual Media Manager in VBox.user@localhost:~/.VirtualBox$ VBoxManage internalcommands createrawvmdk -filename ./WindowsXP.vmdk -rawdisk /dev/sda -partitions 1 -mbr ./MBR.mbr -relative -register
VirtualBox Command Line Management Interface Version 3.0.4_OSE
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
RAW host disk access VMDK file ./WindowsXP.vmdk created successfully.
- If you get permission denied, double check those user permissions. If you are getting access denied at this stage, there isn’t a chance that VBox will! So review from step 1 again…
- Fire up VirtualBox OSE and create a new Windows XP Virtual Machine, choosing the new hard disk you created in step 7
- Important: Now go back into the new Virtual Machine’s settings to enable IO-Apic
- Now boot it up!
I encountered a rather frustrating issue that prevented me booting up my Windows XP partition:
A disk read error occurred
Press Ctrl+Alt+Del to restart
To circumvent this, after lots of searching and reading I realised that the people that have successfully booted had something in common in their vmdk file. Edit the vmdk file you created in Step 7 and change
ddb.geometry.biosHeads=”255″ to ddb.geometry.biosHeads=”240“
Save and watch proudly as Windows XP boots from a raw partition under Linux
Booting your native Windows XP – Keyboard and Mouse not working after installing Guest Additions: Uninstall Guest Additions.
Unfortunately I’ve not come across a nice solution to this. After booting into Windows XP from within Linux, after getting frustrated if the speed isn’t what you expect, there may be a reason to boot back into Windows XP natively. The problem you may come across though is that after installing Virtual Box Guest Additions, it replaced your mouse and keyboard drivers. This is great for running Windows XP under Linux, but not so great when that hardware disappears!
So – uninstalling Virtual Box is all I’ve come across so far. This seems correct as of version 3.0.4. Reports of it working with older (2.2.2) have been unconfirmed by me.
After some googling the following helped me set up my raw Windows XP from within Linux