Booting process of the Linux operating system

The following are the 6 high level stages of a typical Linux boot process:

BIOS (Basic Input/Output System): The BIOS program is written into permanent read-only memory and is always available for use. The BIOS tests the system, checks peripherals, and then looks for a drive to use to boot the system. Once Linux is installed on the hard drive of a system, the BIOS looks for a Master Boot Record (MBR) starting at the first sector on the first hard drive, loads its contents into memory, then passes control to it.

MBR (Master Boot Record): It is located in the 1st sector of the bootable disk. Typically /dev/hda, or /dev/sda. It contains instructions on how to load the GRUB (or LILO) boot-loader, using a pre-selected operating system. If boot-loader is installed in the MBR then load the boot-loader which takes over the process. In the default Linux configuration, GRUB uses the settings in the MBR to display boot options in a menu.

GRUB (Grand Unified Bootloader): This boot method is called direct loading because instructions are used to directly load the operating system, with no intermediary code between the boot-loaders and the operating system’s main files. If you have multiple kernel images installed on your system, you can choose which one to be executed. GRUB displays a splash screen waits for few seconds; if you don’t enter anything, it loads the default kernel image as specified in the grub configuration file (/boot/grub/grub.conf).

Kernel: It Mounts the root file system as specified in the “root=” in grub.conf and executes the /sbin/init program. Since init was the 1st program to be executed by Linux Kernel, it has the process identification number of 1 (PID).

Initial RAM Disk (initrd) is used by kernel as temporary root file system until kernel is booted and the real root file system is mounted. It also contains necessary drivers compiled inside, which helps it to access the hard drive partitions, and other hardware.

Init: When init starts, it becomes the parent or grandparent of all of the processes that start up automatically on your Linux system. This looks at the /etc/inittab file to decide the Linux run level. Then init continues to read the /etc/inittab file, which describes how the system should be set up in each run level and sets the default run level. After having determined the default run level for your system, init starts all of the background processes necessary for the system to run by looking in the appropriate directory for that run level.

Run Level Program: When the Linux system is booting up, you might see various services getting started. For example, it might say “starting sendmail …. OK”. Those are the runlevel programs, executed from the run level directory as defined by your run level. A run level program is a configuration of processes. Depending on your default init level setting, the system will execute the programs from one of the following available run level directories.

Run level 0 – /etc/rc.d/rc0.d/

Run level 1 – /etc/rc.d/rc1.d/

Run level 2 – /etc/rc.d/rc2.d/

Run level 3 – /etc/rc.d/rc3.d/

Run level 4 – /etc/rc.d/rc4.d/

Run level 5 – /etc/rc.d/rc5.d/

Run level 6 – /etc/rc.d/rc6.d/

Typically you would set the default run level to either 3 or 5.