6 STAGES OF LINUX BOOT PROCESS

Sutapa Ganguly
4 min readDec 27, 2023

--

6 stages of Linux boot process

In this beautiful digital world, we have seen work getting done in minutes. All thanks to one of the greatest inventions of all time, COMPUTERS. But most of us who earn our bread and butter from this immensely man-made guineas machine, are not aware of what’s happening inside this compact thin box. Let’s get familiar with the process of going inside and know our friend a little better!

Overview of the 6 stages of the Linux Boot Process:

  1. Stage 1 : BIOS
  2. Stage 2 : MBR
  3. Stage 3 : GRUB
  4. Stage 4: Kernel
  5. Stage 5 : Init
  6. Stage 6 : RunLevel Programs

Let’s Know the Process in Depth

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

⭐️Stage 1: BIOS (Basic Input / Output System)

▶️ BIOS stands for basic input /output system.

▶️ First Program that is executed which is stored in the motherboard of
computer.

▶️ Performs POST ( Power on self Test ), and verifies the hardware
components and peripherals to ensure if computer is in working
condition.

▶️ Searches, Loads, and Executes the boot loader. It looks for a boot loader
in floppy, hard drive, and CD-ROM.

▶️ Once the boot loader program is detected and loaded into the memory,
BIOS hands the control to it.

So, in simple terms BIOS loads and executes the MBR.

Apart from BIOS, UEFI( Unified Extensible Firmware Interface ) is Used.

⭐️ STAGE 2: MBR (MASTER BOOT RECORD)

▶ It is located in the 1st sector of the bootable disk. Typically /dev/hda, or /dev/sda ( Device files are specified based on the controller they are using, if its an IDE controller device then the file name is hda/hdb/hdc and if the device have SCSI or SATA controller then the file name is sda/sdb/sdc )

▶️ MBR is less than 512 bytes in size. It has 3 components i.e primary boot loader info in 1st 446 bytes, Partition table info in next 64 bytes and mbr validation check in last 2 bytes

▶️ It contains information about GRUB or GRUB2(or LILO )

📓 read more on GRUB vs GRUB2

So, in simple terms MBR loads and executes the GRUB boot loader.

⭐️ STAGE 3: GRUB (GRAND UNIFIED BOOT LOADER)

▶ ️If you have multiple kernel images installed on your system, you can
choose which one to be executed.

▶️ GRUB displays a splash screen, and waits for few seconds, if you don’t
enter anything, it loads the default kernel image as specified in the grub
configuration file.

▶️ GRUB knows about the filesystem (the older linux loader LILO didn’t
understand the filesystem).

grub.conf example

▶️ GRUB configuration file is present inside /boot/grub/grub.conf

▶ ️In the above image file you will notice that it contains kernel and inird
image. So, in simple terms, GRUB just loads and executes Kernel and
initrd images.

Once it loads Kernel, it passes control to it.

⭐️STAGE 4: KERNEL

▶️ Mounts the root file system as specified in the “root=” in grub.conf

▶️ Kernel Executes the /sbin/init program.

▶️ Since init was the 1st program to be executed by Linux Kernel, it has the
process id (PID) of 1. Do a ‘ps-ef | grep init ’ and check the PID.

▶️ initrd stands for Initial RAM Disk.

▶️ initrd is used by Kernel as a 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.

⭐️ STAGE 5 : Init

▶️ Looks at the /etc/init tab file to decide the Linux run level

▶️ The following are the available run levels -
1. 0 - halt
2. 1- single user mode
3. 2- Multiuser, without NFS
4. 3 - Full multiuser mode
5. 4 - Unused
6. 5 - X11
7. 6 - reboot

▶️ Init identifies the default init level from /etc/init tab and uses that to
load all appropriate programs.

▶️ Execute ‘grep initdefault /etc/inittab’ on your system to identify the
default run level.

▶️ If you want to get into trouble, please set the default run level 😆to 0 or
6 now that you know what those are used for 😑 !

▶️ Typically all users sets the default run level to 5 or 3.

⭐️ STAGE 6: RUNLEVEL PROGRAMS

▶️ When the Linux system is booting up you will notice several services
starting up like “starting sendmail ….. OK,” These are run-level programs
and are getting executed from the run-level directory, defined by your
run level.
▶️ Please note that there are also symbolic links available for these
directories under /etc directly. So, /etc/rco.d is linked to /etc/rc.d/rco.d

▶ Under the /etc/rc.d/rc.d* directories, you would see programs that start
with S and K.

▶ Programs start with S are getting used to startup. S represents Startup.

▶️ Those programs starting with K are used to stop or shut down. K for Kill.

I hope this article helped you to understand the 6 stages of Linux boot process. Happy learning 👋!

--

--

Sutapa Ganguly
Sutapa Ganguly

Written by Sutapa Ganguly

An Explorer by passion and profession !

No responses yet