9.1. Introduction to the Linux Boot Process

The very first thing that happens when a PC starts up is the loading of the BIOS from ROM. The BIOS (Basic Input/Output System) performs memory and other hardware checks, and then loads a tiny piece of code from the first part of one of the system's hard disks—known as the master boot record or MBR. This piece of code is called a boot loader, and is responsible for displaying a menu of operating systems to the user and loading one of them. There are several boot loaders available for Linux, such as LILO and GRUB, but they all do basically the same thing.

Once the kernel has been loaded, it mounts the root filesystem and runs the init program, which is responsible for managing the rest of the boot process. It reads the /etc/inittab file and executes the commands it specifies—the most important of which begins execution of bootup scripts. Each of these scripts is responsible for a single task, such as initializing network interfaces, starting a web server, or mounting other filesystems. The scripts have a fixed order in which they must execute because some of the later scripts are dependant on earlier ones. For example, network filesystems cannot be mounted until network interfaces have been enabled.

At shutdown time, a series of scripts is also run to shut down servers and unmount filesystems. These scripts also have a fixed order so that the deactivation of networking and other basic services happens last. If requested and supported by the hardware, the last step in the shutdown process will be the powering off of the system by the kernel.

When a Linux system starts up, different scripts are executed depending on the runlevel in which it is starting. The runlevel can be set by the boot loader or by the /etc/inittab file.

The commonly used runlevels are:

5 – Graphical mode All servers and services will be started, and X started to display a graphical login prompt on the console.

3 – Multi-user mode All servers and services are started, but only the normal text login is available on the console.

2 – Multi-user mode without NFS Almost all servers and services are started, but NFS filesystems are not mounted.

1 – Single user mode Only the most basic system initialization is done, and a root shell opened on the console. This runlevel is useful if some bootup script is failing and making your system unbootable.

See Section 9.9 “The SysV Init Configuration Module” for information on how to change the bootup runlevel.

The directory /etc/rc.d/init.d is usually used to store the actual bootup shell scripts. The scripts that are started or stopped in each runlevel are determined by symbolic links from the /etc/rc.d/rcX.d directory, where X is the runlevel number. Each symbolic link has a name like SYYscriptname, in which YY is the order that the script is started in the boot process—the lower the number, the earlier the script starts. So /etc/rc.d/rc5.d/S10network would be run in runlevel 5 before /etc/rc.d/rc5.d/S80sendmail.

Not all Linux distributions use these directories for their bootup scripts. Some use /etc/init.d for the actual script files, while others (such as older versions of SuSE) put everything in the /sbin directory. Fortunately, /etc/rc.d seems to be becoming the standard base directory in newer distributions. Of course, if you are using Webmin you don't have to worry about the locations of any of these directories as it always knows where they are.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.222.231