LINUX Boot Process


Linux boot process includes 3 stages:
1. The BIOS Stage
2. The bootloader Stage
3. The Kernel Stage


The BIOS Stage
The Linux boot process starts with the BIOS stage. The basic input/output system, BIOS is a small memory module on the motherboard. It's used during the boot process to initialize a system's hardware components.
The BIOS uses the information stored in the C MOS chip - another memory module on the motherboard that contains information about the system's hardware configuration.

During the boot process, the BIOS tests that all the hardware components on the motherboard are working. This is known as the power-on self-test (POST).


After performing the POST, the BIOS locates the drive or disk from which the OS must be booted. Typically it is configured to attempt to boot from a sequence of different devices in a certain order - so if the first listed device isn't available or doesn't work, the next one can be used. For a drive to be bootable, it must have a Master Boot Record (MBR) in it's first sector which is known as the boot sector. You need to format a disk to add an MBR to it's boot sector. You can also configure a system's hard disk as the primary boot disk and an optical drive as a secondary boot disk. This ensures that you can boot the OS from a removable disk if the main hard disk fails and the computer won't boot normally.

Bootloader Stage
After the BIOS stage, the bootloader stage involves loading two types of pre-cursor software into memory. The first pre-cursor software that's loaded during the bootloader stage provides enough information for the OS to be loaded into memory. The bootloader is usually found in the MBR of the boot disk. After the bootloader is loaded, the CPU can access the disk and memory(RAM). The other pre-cursor software that's loaded during the bootloader stage is an image of a temporary virtual file system called the initrd image or initial RAMdisk. This prepares the system so that the actual root file system can be mounted. It performs steps such as detecting the device that contains the file system and loading required modules. At the end of the bootloader stage, the bootloader loads the kernel into memory.

The Kernel Stage
In the kernel stage, the virtual root file system created by the initrd image runs the Linuxrc program. This program prepares the real file system for the kernel and then dismounts the initrd image.

The Kernel checks for new hardware and loads any required device drivers. If then mounts the actual root file system. Finally, it runs the init process.

The init process uses the parameters in the /etc/inittab file to load the rest of the system daemons. Once this process finishes, you can log in and use the system.

The most common bootloaders for Linux are LILO(Linux Loader) and GRUB (Grand Unified Bootloader). Both these bootloaders enable you to choose which OS kernel to load during boot time.