A number of features make GRUB preferable to other boot loaders available for the x86 architecture. Below is a list of some of the more important features:
GRUB provides a true command-based, pre-OS environment on x86 machines. This affords the
GRUB supports Logical Block Addressing (LBA) mode. LBA places the addressing conversion used to find files in the hard driver’s firmware, and it is used on many IDE and all SCSI hard devices. Before LBA, boot loaders could encounter the 1024-cylinder BIOS limitation, where the BIOS could not find a file after that cylinder head of the disk. LBA support allows GRUB to boot operating systems from partitions beyond the 1024-cylinder limit, so long as the system BIOS supports LBA mode. Most modern BIOS revisions support LBA mode.
GRUB can read
ext2
partitions. This allows GRUB to access its configuration file,
/boot/grub/grub.conf
, every time the system boots, obviating the need for the user to write a new version of the first-stage boot loader to MBR when configuration changes are made. The only time a user would need to reinstall GRUB on the MBR is if the physical location of the
/boot
partition is moved on the disk. For details on installing GRUB to the MBR, see the
If GRUB was not installed during the Red Hat Linux installation process, you can install it afterwards and it will automatically become the default boot loader. Before installing GRUB, make sure you have the latest GRUB package available, or use the GRUB package from the Red Hat Linux installation CD-ROMs.
| Cross-Reference |
For instructions on installing packages, see Chapter 6. |
Once the GRUB package is installed,
/sbin/grub-install /dev/hda
The
When configuring GRUB, it is important to understand the way in which it refers to devices on any particular system. The device naming conventions
The first hard drive of a system is called (hd0) by GRUB. The first partition on that drive is called (hd0,0) , and the fifth partition on the second hard drive is called (hd1,4) . In general, the naming convention for file systems when using GRUB breaks down in this way:
( < type-of-device > < bios-device-number > , < partition-number > )
The parentheses and comma are very important to the device naming conventions. The
type-of-device
refers to whether a hard disk (
hd
) or floppy disk (
fd
) is being specified. The
bios-device-number
is the number of the device according to the system’s BIOS, starting with 0. The primary IDE hard drive is numbered 0, while the secondary IDE hard drive is numbered 1. The ordering is
| Note |
GRUB’s numbering system for devices starts with 0, not 1. Failing to make this distinction is one of the most common mistakes made by new GRUB users. |
The
partition-number
relates to the number of a specific partition on a disk device. Like the
bios-device-number
, the partition numbering starts at 0. While most partitions are specified by
GRUB uses the following rules when naming devices and partitions:
It does not matter if system hard drives are IDE or SCSI. All hard
To specify an entire device without respect to its partitions, simply omit the comma and the partition number. This is important when telling GRUB to configure the MBR for a particular disk. For example, (hd0) specifies the MBR on the first device and (hd3) specifies the MBR on the fourth device.
If a system has multiple drive devices, it is very important to know the drive boot order set in the BIOS. This is rather simple to do if a system has only IDE or SCSI drives, but if there is a mix of devices, it can become confusing.
When typing commands to GRUB involving a file, such as a menu list to use when allowing the booting of multiple operating systems, it is necessary to include the name of the file immediately after specifying the device and partition. A sample file specification to an absolute file
( < type-of-device > < bios-device-number > , < partition-number > \ ) /path /to/file
Most of the time, a
0+50,100+25,200+1
This blocklist tells GRUB to use a file that starts at the first block on the partition and uses blocks 0 through 49, 99 through 124, and 199. Knowing how to write blocklists is useful when using GRUB to load operating systems that use chain loading, such as Microsoft Windows. It is possible to leave off the offset number of blocks if starting at block 0. As an example, the chain loading file in the first partition of the first hard drive would have the following name:
(hd0,0)+1
The following shows the chainloader command with a similar blocklist designation at the GRUB command line after setting the correct device and partition as root:
chainloader +1
Some users are
With Red Hat Linux, once GRUB has loaded its root partition, which equates to the /boot partition and contains the Linux kernel, the kernel command can be executed with the location of the kernel file as an option. Once the Linux kernel boots, it sets its own root file system. The original GRUB root file system and its mounts are forgotten; they existed only to boot the kernel file. Refer to the root and kernel commands in the “GRUB Commands” section of this chapter for more information.