GRUB Legacy

GRUB (GRand Unified Bootloader) is the default bootloader on Gentoo. This article discusses  (slot zero) also known as "Grub Legacy". Version 2, now available in the testing tree, is completely reworked and fundamentally a different bootloader — see GRUB2.

Installation
Install grub with:

Specifying slot 0 will make sure grub:2 will not get installed on world updates, unless you specifically install it.

Things you may want to consider when using grub
When grub is booting, the numbering of the harddisks is the one from BIOS. This has to go into grub.conf.

Instead of installing grub in the MBR, you may want to use mbr.bin from the syslinux package. This is self contained and boots the partition, which is activated. Grub then goes into the activated partition.

Because grub, when booting, gets his information from the bios, it is able to chainload things, even if the running linux can't see them. One example is a bios supported software raid. When the physical drives are set up as 2 logical drives, the second logical drive starts in the middle of the physical drives. Without using or support of dmraid for this, linux does not see the second logical drive. But grub can chainload windows on it.

If installing windows and linux on a computer with two drives, it may be desirable to install each OS on one of the disks. Before installing, change the boot order in the bios. After installation, you make the windows disk the second disk and use grub to chainload it. This way, by reinstalling windows, the MBR of the first disk won't get affected and if grub can't boot, you can still boot windows by changing the boot order in the bios.

If you chainload windows with grub, you have to give grub the active partition of windows. This is not always the same as the partition, which windows labels the startpartition.

Example of installing grub on an USB harddisk
The key to understand grub is to remember, in what environment grub is running.

Suppose you have 3 internal sata disk. Your gentoo is running on them and you want to install grub now on an external USB hard disk to boot a version of gentoo, which is installed on the second partition of the USB disk.

The linux system has the following device names:

''/dev/sda, /dev/sdb /dev/sdc - internal drives

/dev/sdd - USB disk ''

The configuration of grub, which he reads while booting, is stored in /boot/grub/grub.conf. menu.lst in the same directory is a symlink to grub.conf.

The kernel and the linux system of the USB drive is installed in /dev/sdd2. So you would edit /mnt/sdd2/boot/grub/grub.conf, if you mounted the USB partition on /mnt/sdd2.

But when grub boots from the USB disk, for him it is the first harddisk.

You would write in grub.conf

In contrast, the kernel sees the USB disk as /dev/sdd, the root= kernel parameter has to contain /dev/sdd2.

Sidenote: rootwait is given, so that the kernel waits until the USB disk is ready

The same applies for the installation of grub. Here you give grub the names, under which linux sees it now. First you chroot into /mnt/sdd2. You fire up grub, give him the root of the USB linux with

and then tell him to install on the MBR of the USB disk with

Consequence: if you want to boot the USB disk, regardless of how many disks are installed, you have to use an initramfs or something else.

If the root= parameter doesn't match the actual configuration, you are not lost. You can edit the lines before booting. How this can be done, is explained in
 * 1) REDIRECT Knowledge Base:Adjusting GRUB settings for a single boot session