[ Team LiB ] |
C.3 The GRUB LoaderMost PCs can be booted from a floppy drive or hard drive; most recently manufactured computers can be booted from a CD-ROM drive. The first sector of a disk, diskette, or partition is known as the boot sector. The boot sector associated with a disk or diskette (the first sector of the disk or diskette) is known as the Master Boot Record (MBR). In order for a diskette or disk to be bootable, it must contain a boot loader, which can reside in:
GRUB is a sophisticated boot loader that can load Linux, Microsoft Windows 3.x and 9x, NT, 2000, XP, and other popular operating systems. Most users install GRUB on the MBR of their system's first hard disk. That way, when the system is started, it boots GRUB, which can be used to load Linux, Microsoft Windows, or another operating system. Unless you direct otherwise, the Red Hat Linux installation procedure automatically installs GRUB. So you don't need to install GRUB; you just need to configure it. Similarly, when you boot by using GRUB, you can also boot parameters to control the boot process; you can specify GRUB's boot parameters by selecting an operating system from GRUB's menu and pressing e. In response, GRUB displays an editor screen that shows the commands associated with the selected operating system, as shown in Figure C-1. Figure C-1. The GRUB editor screenCommands that can be used in the editor screen are listed in Table C-1.
The principal GRUB commands are:
GRUB refers to hard disks using the syntax (hdn), where n specifies the device number assigned by the system BIOS. For example, (hd0) refers to the first hard drive. Partitions are designated by the related syntax (hdn,m), where m is the number of the partition. For example, (hd1,0) refers to the first partition of the second hard drive. GRUB can refer to the disk blocks that comprise a file by using a special syntax known as a blocklist. A blocklist consists of a comma-separated list of block ranges, each of which consists of a starting block number, followed by a plus sign (+), followed by the number of blocks in the range. For example, the blocklist 0+1,10+20 refers to a block range beginning at block 0 and including 1 block and a block range beginning at block 10 and including 20 blocks. If the starting block number of a block range is omitted, the block range is implied to begin with block 0. For example, the block range +1 begins at block 0 and includes 1 block. A blocklist can appear after a reference to a partition; if no partition is identified, the partition identified by the preceding root command is implied. For example, in: root (hd0,0) chainlist +1 the blocklist +1 is implicitly associated with (hd0,0) and is equivalent to the blocklist (hd0,0)+1. A typical GRUB entry for booting Linux resembles the following: root (hd0,0) kernel /boot/vmlinuz-2.4.18-14 root=LABEL=/ initrd /initrd-2.4.18-14.img This entry boots the specified kernel residing on partition 0 of the first hard drive, mounting the partition labelled "/" as the root partition. Linux boot parameters, such as those described in the upcoming Section C.4, can be specified by using the kernel command. If the kernel requires access to special drivers residing on a RAM disk, a RAM disk can be identified as in this entry: root (hd0,0) kernel /boot/vmlinuz-2.4.18-14 ro root=LABEL=/ initrd /initrd-2.4.18-14.img Notice that the name of the RAM disk file is specified as though the file resides in the root directory, whereas it actually resides in the /boot directory. This is necessary because GRUB initially mounts the /boot filesystem, as specified in the preceding root command. The mounted filesystem is treated by GRUB as its root filesystem. A typical GRUB entry for booting a Microsoft operating system has this form: rootnoverify (hd0,0) chainloader +1 This entry boots the Microsoft operating system residing on partition of the first hard drive. The blocklist +1 points to the first block of the root partition. Microsoft operating systems place their boot file at this location. To boot your system, GRUB uses your system's BIOS, which may not be able to load a Linux kernel (or other program) stored beyond cylinder 1023 of your hard drive. Booting a kernel stored beyond cylinder 1023 requires a motherboard that supports logical byte addressing (LBA). Most motherboards manufactured in the last several years are supposed to support LBA. Unfortunately, some motherboards that claim to support LBA do not. If you're installing Linux on a preexisting hard drive, you may not be able to place your Linux kernel in an appropriate location. In that case, you won't be able to use GRUB to boot your system. To learn more about GRUB, see the following resources:
|
[ Team LiB ] |