GRUB Legacy

GRUB (GRand Unified Bootloader) is the default bootloader on Gentoo. This article discusses  (slot zero) also known as "Grub Legacy". Version 2 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 hard disks is the one from BIOS. This has to go into.

Instead of installing GRUB in the MBR, you may want to use from the  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 hard disk
The key to understand GRUB is to remember, in what environment GRUB is running.

Suppose you have 3 internal SATA disks. 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: The configuration of GRUB, which he reads while booting, is stored in . in the same directory is a symlink to.
 * , and : internal drives
 * : USB disk

The kernel and the Linux system of the USB drive is installed in. So you would edit, if you mounted the USB partition on.

But when GRUB boots from the USB disk, for him it is the first hard disk.

You would write in

In contrast, the kernel sees the USB disk as, the  kernel parameter has to contain.

Sidenote:  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. 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  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 Knowledge Base:Adjusting GRUB settings for a single boot session

To get the USB disk boot without initramfs regardless of the number of installed disks, you can use a GPT partition table and the  kernel parameter as explained in this external link: Mounting root partition by UUID (no initrd needed)

Since kernel 3.8 and newer it is possible to use MBR 32-bit UUID, so you can use a MBR partition table as well.

In this case PARTUUID refer to an MBR partition using the format SSSSSSSS-PP, where SSSSSSSS is a zero-filled hex representation of the 32-bit "NT disk signature", and PP is a zero-filled hex representation of the 1-based partition number.

To get "NT disk signature" you may use fdisk:

You will get something like, so assuming root partition is , the resulting line will be

More info is available here: Description of PARTUUID feature

To use the  or the   boot parameter, you have to use an initramfs. An example of using labels (with lilo) can be found here: Install Gentoo on a bootable USB stick