Monday, August 16, 2010

Boot loaders and dual boot systems

Install order no longer matters
Once upon a time it used to matter which order you installed your operating systems when trying to dual boot Windows and Linux/Unix systems. Today that no longer matters and you can install your operating system in any order. The only thing you really need to remember is that your Windows operating system will almost certainly require at least 1 primary partition and so will your Linux system.

Re-instantiating GRUB
If you do decide to install or re-install Windows once you've installed Linux then you'll need to re-instantiate your GRUB boot loader as the primary boot loader. Here are the steps to perform this, for those of you like me who use Linux as their primary OS, but due to the rest of the world who seem to think they have to use Windows or MAC OS and you do work for these companies, here are the steps to recovering your boot loader after installing Windows without having to re-install Linux.
  1. Boot your system using the Linux installation disk
  2. On some versions of Linux, e.g. Fedora 12 you might want to change the rescue option so that it just has linux rescue instead of all the other options. To do this select the linux rescue option and press tab, then delete the line and type linux rescue
  3. Follow the instruction up to the point it asks you to find installed systems
  4. Tell it to skip
  5. Then select shell option for a command line
  6. Type fdisk -l to see the hard disks on your system
  7. Hopefully you remember which one contains GRUB (the /boot) directory since this is the one you now need to set to primary boot
  8. Type fdisk /dev/XXX where XXX is the name of the device you wish to change the boot flag
  9. If you can't remember the option to toggle the boot flag type m and press enter
  10. Type p to print the partition table and note which partition has the * as this is the current boot partition
  11. Type the letter a to change the boot flag
  12. Type the number of the partition that currently has the *
  13. Type a and then type the number of the partition that contains the GRUB boot loader
  14. Type w to save the partition table
At this stage you should reboot the system as normal to see if your grub boot loader re-appears. This should be enough to do it. If it does not then;
  1. Start the system from the Linux install media as above, but this time do tell the system to search for Linux installations
  2. If it successfully finds your Linux installation it will generally mount it to /mnt/sysimage
  3. cd /mnt/sysimage
  4. chroot /mnt/sysimage
  5. Now we wish to re-install the GRUB boot loader. To do this type grub-install /dev/XXX where XXX is the disk and partition number where GRUB should be installed, that is where the /boot directory is
  6. Provided that your GRUB boot loader is in /boot, if it's not then you will need to look at the man page to see what option you need
Once done your system will reboot with the GRUB boot loader, and as long as you know the GRUB options to make Windows boot you should be able to add this to your boot loader.

Typical grub.conf Windows settings are;
rootnoverify (hd0,0)
chainloader +1

Where hd0,0 is the disk number and partition number where Windows boot loader resides.

No comments:

Post a Comment