Retrieving Grub

Q At present I dual boot between XP Pro on drive C and PCLinuxOS on drive D. It's time for a reinstall of XP, but I have PCLinuxOS set up pretty well the way I want it and don't want to start all over again with it. I also don't want to lose the dual booting. Is it possible to perform a complete reinstall of XP without losing the dual booting? Or is there a way that I can restore the dual boot after XP installation ?

A Installing Windows will get rid of whichever bootloader you use for Linux (Grub in the case of PCLinuxOS). This is why, when setting up a dual boot machine, it is always best to install Windows first. However, it's a simple task to restore your boot setup, because Windows will only overwrite the bootloader code in the disk's Master Boot Record (MBR), it will not touch your menu configuration. To restore your dual boot, you need to run Grub, which you can do from almost any Live CD distro. Boot from the CD (or DVD), open a terminal and log in as root by running su or sudo bash if you use an Ubuntu CD. You can run the automatic install script as

grub-install /dev/sda

although this does not always work well with multiple drive systems. The alternative is to install it manually, which requires only two commands anyway. You need to identify your drives and partitions, because Grub uses a different labelling scheme. The first hard drive is (hd0), the first partition on that drive is (hd0,0). Note that Grub counts from zero. The two locations you must identify are the location of the /boot/grub directory, which will be (hd1,0) if it is the first partition of the second drive, and where you want the bootloader code installed, which is usually (hd0), if you want to put it in the MBR of the first drive. Once you know where everything goes, run grub to enter the Grub shell, then run

root (hd1,0)
setup (hd0)

The first command identifies the location of the Grub files, the partition containing the /boot/grub directory; the second command writes the initial bootloader code to the MBR, the meaning of the third command will be left as a mystery. Provided this all ran with no errors, a reboot should show your original boot menu in all its glory. Alternatively, you could save yourself a lot of grief and remove XP entirely.

Follow us on or Twitter

Username:   Password: