Linux Boot Process
By: Sahil Sardana
Tags: Linux Boot Process, Linux Tutorial, Linux

Hello Everyone, Today I would like to share the exact workflow or the process when a Linux server starts:

There are Basically 6 Steps which are followed when a server starts:

BIOS Test or Also called POST which means Power On Self Test, This step is common among every system whether a Linux server or Windows machine. This test checks for all the hardware connected with your machine if that is working correctly. If this test fails then the machine will not start further. BIOS sends an interrupt which the boot sectors on the attached devices. The first boot sector it finds that contains boot record is loaded into RAM and then control is transferred to the code that was loaded from the Boot Sector. This is called Master Boot Record. MBR : MBR Stands for Master Boot Record, located on the first sector of a bootable device /dev/sda

MBR Stores 512 Bytes and it has 3 parts:

a. Primary boot loader info is stored and uses 446 bytes

b. partition table info is stored in 64 Bytes.

c. MBR Validation check stored in the last 2 bytes.

Boot Loader is of 3 Types GRUB, GRUB2 and LILO.

3. GRUB : GRUB stands for Grand Unified BootLoader. If you have more than 1 Operating System then it will be mentioned in the Grub configuration file, it is /etc/grub/grub.conf . The default kernel is mentioned, it waits for few seconds to select and if it timesout then the default OS is selected.

This file has kernel information and the initrd image. Grub loads and executes kernel and initrd image.

4. Kernel : When Kernel Loads it mounts the Root File System and executes the /sbin/init program. Now as the drivers are not there how does kernel loads the root volume ? The answer is that it reads the initrd or initramfs.

initrd acts as a block device, thus requiring a filesystem driver (such as ext2 ). The kernel must have at least one built-in module for detecting filesystem of initrd . InitiRD stands for Initial Ram Disk. Initrd then provides the necessary modules to load the root file system.

5. Init : This checks for file /etc/inittab to decide the Linux Run Level.

There are 7 run levels in Linux OS as :

0 — halt

1 — Single User Mode

2 — Multiuser mode without NFS

3 — Full Multi User Mode

4 — unused

5 — X11

6 — Reboot

Init will check and identifies the default initlevel from file /etc/inittab to load all appropriate program required for the run level.

you can check you system’s configured default run level by running command:

grep initdefault /etc/inittab

6 : RunLevel

Once the default Run Level is identified, it will execute all the required programs defined at that run level. The system will check and execute the run level programs from the following 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/

There is a symbolic link linked directory also available in /etc directory , /etc/rc0.d. You can also check all the programs inside /etc/rc.d/rc<n>.d/ which is starting with S or K, which basically tells the order in which the programs will start S Stands for Startup and K stands for Kill or Stopping service order.