Installing GRUB

The simplest way to install GRUB is to use the grub-install script.

For example, to install GRUB on the master boot record of the first hard drive in a system, invoke grub-install as follows:

# grub-install '(hd0)'

grub-install looks for a device map file (/boot/grub/ by default) to determine the mapping from BIOS drives to Linux devices. If this file does not exist, it will attempt to guess what devices exist on the system and how they should be mapped to BIOS drives. If grub-install guesses incorrectly, just edit /boot/grub/ and rerun grub-install.

The device map file contains any number of lines in this format:

(disk) /dev/device

So, for example, on a system with a floppy and a single SCSI disk, the file would look like this:

(fd0)   /dev/fd0
(hd0)   /dev/sda

GRUB can also be installed using the grub command. The grub-install example shown earlier could also have been done as follows, assuming /boot is on the first partition of the first hard disk:

# grub
grub> root (hd0,0)
grub> setup (hd0)

Get LPI Linux Certification in a Nutshell, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.