How to dual boot linux and XP the hard way.
So you've been happily running your workstation on Ubuntu, and you have need to dual boot into XP as well. For me, I needed to run some performance tests, and my 2001 Toshiba laptop just wasn't up to the task. When you built your workstation, you chose the default full disk install, so you've got
- /dev/sda1 OS
- /dev/sda2 Extended
- /dev/sda5 swap
Which makes things tedious, no easy way to install XP without a lot of fooling around.
There are 3 separate tasks that need to be performed toconvert your workstation to a dual linux/XP boot machine:
- Repartition
- Install XP
- Reinstate the bootloaded
Repartition
So the disk is ext3 ( the default ), so there's no way you can just resize it ( downwards ) whilst it's booted. So, reboot off a live distro ( I used knoppix for old times sake ), and perform the following ( I'm shrinking down to 250GB to allow for 50GB for the XP installation ):
e2fsck -f /dev/sda1 resize2fs /dev/sda1 256000M e2fsck /dev/sda1
This has resized the file system ( it took a while with this 320GB->250 resize - I did it overnight ), so we now need to repartition the file system instead. It's recommended to make the partition a bit bigger than the file system just to be sure, so I used fdisk to end up with the following on my 320GB disk ( at this point I didn't worry bout swap being in the wrong place - system'll come up first time without it and I'll sort it then
fdisk -l /dev/sda Disk /dev/sda: 320.0 GB, 320072933376 bytes 255 heads, 63 sectors/track, 38913 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00082c6b Device Boot Start End Blocks Id System /dev/sda1 * 1 32681 262510101 83 Linux /dev/sda2 * 32682 38761 48837600 7 HPFS/NTFS /dev/sda3 38762 38913 1220940 82 Linux swap / Solaris
Note that there are 2 active partitions: if you don't set the XP partition active, then the install will. OK that's thescary stuff over. If you've not had any reeors, then the rest's plain sailing!
Install XP
I stuffed my trusty old XP Pro install disk in the CD and completely failed to recognise the partitions on the disk. An hour or so later ( thanks to the bosses Vista machine and samba! ) I'd slipstreamed SP's 2 and 3 in and created a new boot disk: I put it onto a DVD as the data transfer rate's faster. This allowed me to boot into the XP into 50GB partition I'd created. I then spent a while getting it up to date, and installing avg
Reinstall GRUB
At the moment, it looks like you've completely lost linux. Never fear - it's just that the Microsoft bootloader that XP installed is ignoring it! You can update it to see both, but I prefer to reinstall install grub - mainly because I normally live inside linux, and I know that it plays nice with XP coexisting. So all that needs to be done is to trash the Microsoft bootloader, and to use grub to manage everything. I had a bit of fun with this, finding a 64 bit live CD to match the installed OS. I had a few problems getting graphics up as well, but eventually managed to boot up a live Gutsy Gibbon CD. Then it's just a case of mounting /dev/sda1, chrooting to it, running grub-install, and then fixing the boot menu.
sudo su - mkdir /target mount /dev/sda1 /target mount -o bind /proc /target/proc mount -o bind /dev /target/dev chroot /target /bin/bash grub-install then use your favourite editor to add the following stanza to /boot/grub/menu.lst title Windows XP root (hd0,1) makeactive chainloader +1 exit to return to the live cd, umount /target/proc umount /target/dev umount /target init 6
Once that is finished, reboot into linux, and fix the swap up
mkswap /dev/sda3
will return the new UUID of the swap area, and use that to update /etc/fstab. Mine now looks like
UUID=4062d320-8ca1-43be-ad07-567eec50cd52 none swap sw 0 0
All's now ready to use.
running
swapon -a
will re-enable swap on your workstation.