Booting process of the Linux

April 15, 2021

In this blog, I am going to walk you through the booting process of the Linux kernel.

Linux Operating System
It is a family of free and open-source, operating systems based upon the linux kernel and was developed by Linus Torvalds. The first version of the Linux kernel was published on September 17, 1991.

Mainly there are 6 steps in which the Linux boots up.
1. BIOS
2. MBR
3. GRUB
4. Kernel
5. Init
6. Run level

We will look into each of these 6 steps in detail now.

1. BIOS (Basic Input Output System)

  • BIOS performs the basic system integrity checks.
  • It searches, loads, and executes the bootloader program.
  • This bootloader program is usually found in disk drives, SD card readers, CD/DVD ROM.
  • Once BIOS executes the bootloader program now the control of the system is transferred to the bootloader.
  • Main function of the BIOS is to load and execute the bootloader program.

2. MBR (Master Boot Record)

  • This MBR is located in the first sector of the bootable disk.
  • It’s usually found in /dev/hda or /dev/sda it depends on the hardware you are using.
  • Total size of Master Boot Record is 512 bytes.
  • There 4 components in MBR.
    1. Primary Boot Loader, of size 2 Bytes.
    2. Partition table information, of size 446 Bytes.
    3. MBR validation check, of size 64 Bytes.
  • It contains the information about GRUB.
  • Main function of MBR is to load and execute the GRUB bootloader.

3. GRUB/GNU GRUB (Grand Unified Boot Loader)

  • GNU stands for GNU’s, not Unix.
  • GNU GRUB is the modern bootloader for a Linux-based operating system.
  • This GRUB is knowing the File System.
  • GRUB loads and executes the file called /boot/grub/grub.conf
  • Once the bootloader loads and executes user will get the splash screen to select the bootloader if the user has installed the multiple kernel images, if the user didn’t select any kernel image default kernel is executed.
  • Initially init rd file is loaded which is Initial ramdisk which acts as root file till original storage is mounted.
  • Main function of GRUB is to load and execute the kernel program.

4. Kernel

  • It is the heart of the operating system.
  • It takes complete control over the system.
  • It mounts the root file system specified in the /boot/grub/grub.conf file.
  • It executes the first program which is init and it is located in /sbin/init.
  • Main function of the kernel is to load file system and run the init program.

5. Init

  • It decides the run level of the Linux kernel.
  • Run level is found in /etc/inittab
  • Run level decides which are the programs to be run during the booting of the system.
  • There are various run levels.
    1 - Single user.
    2 - Multiuser without NFS(Network File System).
    3 - Multiuser with no GUI.
    4 - Unused.
    5 - Multiuser with GUI.
    6 - Reboot.
  • Main function of the Init program is to decide the run level.

6. Run Level

  • Run levels are nothing but the various type of services.
  • Run level executes the run level program which is decided by the user during the Init program.
  • There are 7 run levels and these run levels are found in different 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/
  • This folder location various for different linux based distribution.
  • Usually these programs start with “S” or “K”, “S” stands for start up program executed during booting of the system and “K” stands for kill which is executed during shutting down the system.

This is how the Linux kernel boots up.

Happy Coding !!!

Reference
GeeksforGeeks

Buy my products at Amazon