Understanding the Linux Boot Process
By Stephen Bucaro
In order to troubleshoot a Linux system that fails to boot, it is important to understand the boot process.
Then we can identify at which stage of the booting sequence the failure occurred.
Immediately after you turn the power on the BIOS (Basic Input Output System) begins to execute.
The BIOS is a firmware program that is built-in to the motherboard. It performs a POST (Power-On Self Test)
and then scans for devices such as Hard Disk, CD-ROM, RAM, etc. Some of these devices also contain pieces
of BIOS code that is loaded. The BIOS then searches for the MBR (Master Boot Record). The MBR is on the
first sector of a disk (Cylinder: 0, Head: 0, Sector: 1). The MBR scans for a boot loader (GRUB or LILO)
and hands the boot process over to the boot loader.
The boot loader GRUB (Grand Unified Boot Loader) or LILO (Linux Loader) loads itself into RAM. Once
loaded into RAM, GRUB reads the the Grub configuration file (/boot/grub/grub.conf), which identifies the
kernel file and the initrd file.
The file /dev/initrd (Initial RAM Disk) is a read-only block device. This device is a RAM disk that
is loaded by the boot loader before the kernel is started. The kernel then can use the contents of
/dev/initrd for a two-phase system boot-up. In the first phase, the kernel starts up and mounts an
initial root file system from the contents of /dev/initrd (a RAM disk).
In the second phase, additional drivers or other modules are loaded from the initial root device's
contents. After loading the additional modules, a new root file system (the normal root file system) is
mounted from a different device. Then the Kernel initialization file is executed.
Kernel initialization includes initialization of CPU components, for example the MMU (Memory Management Unit).
Then initialization of the scheduler (Process 0) which starts a child process (process 1), then process 0
becomes the swapper process (also known as the "idle task").
Then Kernel initialization mounts the root file system and starts the core system of shared resource
managers (RAM, processor and mass storage).
Process 1, /sbin/init, known as init, is the ancestor of every other process in the system. It loads all
the various daemons and mounts all the partitions which are listed under /etc/fstab. Init identifies the
default initlevel from /etc/inittab to identify the default run level and to load all appropriate programs.
Two of the programs it loads are the X display manager and the User's login screen.