Home » Linux » Linux Boot Process – Step-by-Step Explained

Linux Boot Process – Step-by-Step Explained

Last updated Sep 4, 2021

As a user, when you press the power button of system, you get the login screen on your monitor and after login starts working.

Have you ever think what is going between you press power button and login screen appear?

There is a boot process for any operating system which executed one-by-one, and finally, you get the Operating system’s login screen.

Here we go through the Linux boot process stage-by-stage.

There are six high-level stages for Linux boot process:

  • BIOS – Basic Input/Output System executes MBR
  • MBR – Master Boot Record execute GRUB
  • GRUB – Grand Unified Bootloader executes Kernel
  • Kernel – Kernel executes /sbin/init
  • Init – Init executes runlevel programs
  • Runlevel – Runlevel programs are executed from /etc/rc.d/rc*.d/
  • Facebook
  • Twitter
  • reddit
  • LinkedIn

Stage 1: BIOS

BIOS stands for Basic Input/Output System. BIOS responsibilities are to search boot loader (GRUB, LILO) program to load and execute it.

BIOS search boot loader into a floppy, CD-rom, or hard drive. You can change the boot sequence from BIOS setup during BIOS startup.

When the boot loader program found and loaded into the memory, BIOS gives the control it. So, BIOS use to loads and execute the MBR boot loader.

Stage 2: MBR

MBR stands for Master Boot Record.

MBR located into the 1st sector of the bootable drive. Generally, /dev/had, or /dev/sda.

MBR stores in 512 bytes in size, there are three components of MBR.

  • Primary boot loader information stored in 1st 446 bytes
  • Partition table information stored in the next 64 bytes
  • MBR validation check stored in the last 2 bytes.

MBR stored information about any boot loader; in our case, it is having information about GRUB boot loader.

In short MBR loads and executes the GRUB boot loader.

Stage 3: GRUB

GRUB stands for Grand Unified Bootloader.

It stores all information about operating system image to load and execute.

If you have more than one operating system, all entry will be in this GRUB file, and you can choose to make the default one.

GRUB display splash screen on system boot and wait for few seconds to get user input to choose the operating system, if you don’t enter anything, it loads the default kernel image as specified in the grub configuration file.

Grub has the knowledge of the filesystem in your operating system.

You can find the GRUB configuration file at “/boot/grub/grub.conf,” the sample of file grub.conf is shown below:

#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (7.2.18-324.el5PAE)
          root (hd0,0)
          kernel /boot/vmlinuz-7.2.18-324.el5PAE ro root=LABEL=/
          initrd /boot/initrd-7.2.18-324.el5PAE.img

As you can see in the file, it has information of kernel and initrd image.

In simple term GRUB loads and executes Kernel and initrd images.

Stage 4: Kernel

When kernel loads, it mount the root file system and execute /sbin/init program. As init was the first program run by the Linux kernel, it has one(1) as process id (PID), which you can check by using below command:

# ps –ef | grep init

The initrd stands for Initial RAM Disk.

Stage 5: Init

It checks file “/etc/inittab” to decide the Linux run level.

There are seven(7) run levels available with the Linux operating system:

  • 0 – halt
  • 1 – single-user mode
  • 2 – Multiuser, without NFS
  • 3 – Full multiuser 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 your system’s configured default run level by executing below command:

$ grep initdefault /etc/inittab

Stage 6: Runlevel

One default run level identified; it will execute all required program for that run level.

The system will check and execute 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 symbolic linked directory also available in “/etc” directory, /etc/rc0.d is linked to /etc/rc.d/rc0.d and so on.

You can check all program under the directory /etc/rc.d/rc*.d/ which is starting with S and K.

The program which starts with S used during startup. S stands for the startup.

The program which starts with K used during shutdown. K stands for Kill.

You can see a number in the name after S or K which are the sequence number in which programs should be started or killed.

These are the 6 stages which are happening behind the screen when you power on the system.

Related Posts

Creating a lame utility HTTP server in Linux Operating System

In this article, we will discuss the cURL tool in Linux. The cURL tool is used for transferring the data from or to a server. It supports many protocols, and http is one of them. cURL is used to transfer the data from URL. It has so many tricks to offer, such as http...

Finding binary dependencies in Linux Operating System

In this article, we are going to check the executable. We will find out which string is present in it by using the string command.PrerequisitesBesides having a terminal open, make sure you have a binary present in your directory.Find dependencies First, we...

Capturing network traffic headlessly in Linux Operating System

In this article, we are going to learn how to capture traffic. We are going to capture network traffic with a packet sniffer tool called tcpdump. This tool is used to filter or capture TCP/IP packets that are transferred or received over a network.PrerequisitesBesides...

Follow Us

Our Communities

More on Linux

The Ultimate Managed Hosting Platform
Load WordPress Sites in as fast as 37ms!

0 Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

thirteen − one =

Shares