Linux Boot Process – Step-by-Step Explained

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 booting 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 step by step. it will helps you to understand the Linux booting sequence from pressing power button to get login screen.

There are six high-level stages for Linux booting 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/
Linux Boot Process step by step
Linux boot process – Flow diagram

Stage 1: BIOS [First step of Linux boot process]

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 loader program found and loaded into the memory, BIOS gives the control it. So, BIOS use to loads and execute the MBR booting loader.

Stage 2: MBR

MBR stands for Master Boot Record. It is more important part for Linux Boot process.

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 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

In the Linux boot process, 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.

FAQ – Linux boot process step by step

Q – How many steps are in Linux boot process?

There are 6 stages of Linux boot process:

  1. BIOS
  2. MBR
  3. GRUB
  4. Kernel
  5. Init
  6. Runlevel

Q – What is BIOS (basic input/output system)?

The BIOS is the first program executed when a computer starts up. It manages hardware resources such as memory, disk drives, video cards, etc. The BIOS also contains code for basic I/O functions like reading from floppy disks, printing text on screen, and controlling the keyboard.

Q – How does BIOS work?

The basic input/output system (BIOS) is the first code executed when a computer starts up. This initial software loads the operating system into memory and then boots the computer from the hard drive. Once the operating system has booted, the BIOS checks for hardware errors such as bad RAM chips, faulty power supplies, and other issues. If any problems exist, the BIOS sends error messages to the screen, which displays them until they are fixed.

Q – What are the four functions of BIOS?

The functions of BIOS include booting up the computer, loading the operating system, hardware detection, and configuration settings. If any one of these functions fails, then the entire computer will stop working.

Q – How to access BIOS?

There are two ways to access the BIOS: 1. Press F2 during boot up 2. Hold down the Del key while powering on the computer.

Q – What is MBR (Master Boot Record)?

The Master Boot Record (MBR) is the first sector of the master boot record on a computer’s hard drive. This area contains information about what operating system needs to be loaded next. If any errors occur while loading software from the MBR, the computer may crash.

Q – What is Grub?

The grub command line tool allows you to boot from one of the installed operating systems on your computer. It also makes it easy to change the default OS used for starting up. This tool has been around since at least 1980s.

Q – What are the difference between Grub and Grub2?

The differences between Grub and Grubs 2 are minimal, but one big change is that Grub2 has been rewritten from scratch. This means that all new features were added to Grub2 instead of just adding them to Grub1. Another major difference is that Grub2 uses systemd for booting and managing Linux systems.

Q – What is Linux kernel?

The Linux Kernel is the core operating system for all computers using the Linux OS. It provides basic functions such as memory management, scheduling tasks, input/output operations, file systems, networking, device drivers, etc.

Q – What is init in Linux?

Init is a process which runs at bootup time and performs various system initialization tasks such as loading modules needed for basic functionality, starting daemons and other processes, and performing any one-time initializations.

Q – What is the runlevel in Linux?

The runlevels in Linux are used to control processes during bootup. 

Q – How many runlevels are supported by Linux Operating System?

There are 6 runlevels in Linux Operating System:

run level 0: turn off (shut down) the computer

run level 1: initiate a rescue shell process

run level 2: multi-user mode without networking

run level 3: configure the system as a non-graphical (console) multi-user environment

run level 4: user-definable

run level 5: establish a graphical multi-user interface with network services

run level 6: restart the machine

Conclusion

In this article, You have learned Linux boot process step by step in each stage, you also learned several booting components like BIOS, MBR, GRUB, Kernel, INIT, and Runlevels.

You also get information of boot process in Linux Operating system with detailed in sequence and now you are familiar with how your Linux system get up and you getting login screen.

If you have any questions regarding Boot process in Linux system you can check our FAQ section and also drop your question in comment section.

0 Comments

Submit a Comment

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

20 − 16 =

Related Articles