The Fedora Boot Sequence
You might remember when you installed Linux that the installation process prompted you for a list of partitions and the sizes of each in which your filesystems would be placed.
When allocating disk space for the partitions, the first sector, or data unit, for each partition is always reserved for programmable code used in booting. The very first sector of the hard disk is reserved for the same purpose and is called the master boot record (MBR).
When booting from a hard disk, the PC system BIOS loads and executes the boot loader code in the MBR. The MBR then needs to know which partitions on the disk have boot loader code specific to their operating systems in their boot sectors and then attempts to boot one of them.
Fedora Linux is supplied with the GRUB boot loader, which is fairly sophisticated and therefore cannot entirely fit in the 512 bytes of the MBR. The GRUB MBR boot loader merely searches for a special boot partition and loads a second stage boot loader. This then reads the data in the /boot/grub/grub.conf configuration file, which lists all the available operating systems and their booting parameters. When this is complete, the second stage boot loader then displays the familiar Fedora branded splash screen that lists all the configured operating system kernels for your choice.
Figure 7.1 shows a typical grub.conf file for a system that can boot both Fedora Linux and Windows 2000. The structure of this file is discussed further in Chapter 33, "Modifying the Kernel to Improve Performance."
Figure 7.1. Example of a grub.conf file.
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Fedora Core (2.6.8-1.521)
root (hd0,0)
kernel /vmlinuz-2.6.8-1.521 ro root=LABEL=/
initrd /initrd-2.6.8-1.521.img
title Windows 2000
rootnoverify (hd0,1)
chainloader +1
When Linux begins to boot with its kernel, it first runs the /sbin/init program, which does some system checks such as verifying the integrity of the file systems, and starts vital programs needed for the operating system to function properly. It then inspects the /etc/inittab file to determine Linux's overall mode of operation or runlevel. A listing of valid runlevels can be seen in Table 7.1.
Table 7.1. Linux RunlevelsMode/Runlevel | Directory Runlevel | Description |
|---|
0 | /etc/rc.d/rc0.d | Halt | 1 | /etc/rc.d/rc1.d | Single-user mode | 2 | /etc/rc.d/rc2.d | Not used (user-definable) | 3 | /etc/rc.d/rc3.d | Full multiuser mode (no GUI interface) | 4 | /etc/rc.d/rc4.d | Not used (user-definable) | 5 | /etc/rc.d/rc5.d | Full multiuser mode (with GUI interface) | 6 | /etc/rc.d/rc6.d | Reboot |
Based on the selected runlevel, the init process then executes startup scripts located in subdirectories of the /etc/rc.d directory. Scripts used for runlevels 0 to 6 are located in subdirectories /etc/rc.d/rc0.d tHRough /etc/rc.d/rc6.d, respectively.
Here is a directory listing of the scripts in the /etc/rc.d/rc3.d directory:
[root@bigboy tmp]# ls /etc/rc.d/rc3.d
... ... K75netfs K96pcmcia ... ...
... ... K86nfslock S05kudzu ... ...
... ... K87portmap S09wlan ... ...
... ... K91isdn S10network ... ...
... ... K92iptables S12syslog ... ...
... ... K95firstboot S17keytable ... ...
[root@bigboy tmp]#
As you can see, each filename in these directories either starts with an S, which signifies the script should be run at startup, or a K, which means the script should be run when the system is shutting down. If a script isn't there, it won't be run.
Most Red Hat/Fedora packages place their startup script in the /etc/init.d directory and place symbolic links (pointers) to this script in the appropriate subdirectory of /etc/rc.d. This makes file management a lot easier. The deletion of a link doesn't delete the file, which can then be used for another day.
The number that follows the K or S specifies the position in which the scripts should be run, in ascending order. In our example, kudzu with a value of 05 will run before wlan with a value of 09.
Fortunately you don't have to be a scripting/symbolic linking guru to make sure everything works right because Fedora comes with a nifty utility called chkconfig to do it for you. This is explained later.
 |