What is GRUB?

The GRand Unified Bootloader is a piece of software that allows you to boot different partitions. In many respects it is similar to LILO. However, LILO does not understand filesystems, but GRUB does. In addition to this, GRUB creates fantastic boot disks that can really save your hide.

Installing GRUB

GRUB is not installed automatically on a Debian system. So to install it, use one of the debian package management tools: apt-get. At a command line, enter the following apt-get install grub grub-doc. This will install both the code and the documntation files. To read the documentation for GRUB, type info grub.

Create a GRUB boot disk

The details of this stage are in the GRUB information, I shall just list the actions.

Insert a blank floppy (or one that has nothing important on it) into the drive. Then type:
dd if=/usr/lib/grub/i386-pc/stage1 of=/dev/fd0 bs=512 count=1
dd if=/usr/lib/grub/i386-pc/stage2 of=/dev/fd0 bs=512 seek=1

This copies the files straight onto the floppy in a format that it can read easily at boot.

Booting from floppy into XP

You can now boot into XP from the GRUB floppy if you want (you might like to try this - think of it as survival training). In order to do so, leave the GRUB floppy in the drive and restart the machine (/sbin/shutdown -r now).

Once the GRUB prompt comes up, type the following commands:
rootnoverify (hd0,0)
chainloader +1

This should now boot into XP.

Booting from floppy into Linux

To boot into Linux, you must type the following commands:
root (hd0,3)
kernel /vmlinuz root=/dev/hda4 vga=768

This should now boot into Linux. Caveat: If your Linux lives in a different partition, then you will need to modify the above, see the GRUB documentation.

Installing GRUB onto the MBR

In order to install GRUB onto the MBR, you should follow the following steps:

On the Linux partition, create a /boot/grub directory. Copy all of the files from /usr/lib/grub/i386-pc to this directory.

Now you should create a file called menu.lst in this directory. The contents of this file should look something like:
default 0
timeout 10
fallback 1
color white/black black/magenta

title linux
root (hd0,3)
kernel /vmlinuz root=/dev/hda4 vga=768

title XP
rootnoverify (hd0,0)
chainloader +1

Now, you should reboot your system with the GRUB floppy. Once you are back at the GRUB prompt, type the following commands:
root (hd0,3)
setup (hd0)

Now remove the GRUB floppy and restart the machine. You should find that when the machine reboots you are presented with two options in a GRUB menu.