Search
Close this search box.

6 Stages of Linux Boot Process (Startup Sequence)

Table of Contents

As promised in our earlier post, we will review the boot process on a Linux Operating System and how the Operating system passes through the different stages of booting states.

 

This article is written for those readers who have just entered the Linux world. Understanding how Linux boots up are essential in effectively troubleshooting in case of system failure. When a system is switched on, and after a few moments,

 

we get a login prompt. Have we tried to find out what all stage of the booting sequence has crossed and what happened behind the scene during the system boots up?

 

What is Linux Boot Process?


The Linux boot process is the sequence of stages the operating system goes through when it is started. During the boot process, the system’s hardware is initialized, the bootloader is loaded, the kernel is loaded into memory, system services are created, and the user interface is presented. The Linux boot process ensures the system is initialized and configured correctly before the user can access it.

 

Booting up Linux involves multiple stages, each with specific tasks to accomplish. These stages include:

 

1. BIOS

  • BIOS stands for Basic Input/Output System
  • Performs some system integrity checks
  • Searches, loads, and executes the boot loader program.
  • It looks for the floppy, cd-rom, or hard drive bootloader. During the BIOS startup, you can press a key (typically F12 or F2, but it depends on your system) to change the boot sequence.
  • Once the bootloader program is detected and loaded into the memory, BIOS controls it.
  • So, in simple terms, BIOS loads and executes the MBR boot loader.

2. MBR

  • MBR stands for Master Boot Record.
  • It is located in the 1st sector of the bootable disk. Typically /dev/hda or /dev/sda
  • MBR is less than 512 bytes in size. This has three components 1) primary boot loader info in 1st 446 bytes, 2) partition table info in the next 64 bytes 3) mbr validation check in the last 2 bytes.
  • It contains information about GRUB (or LILO in old systems).
  • So, in simple terms, MBR loads and executes the GRUB boot loader.

3. GRUB

  • GRUB stands for Grand Unified Bootloader.
  • 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 a few seconds; if you don’t enter anything, it loads the default kernel image as specified in the grub configuration file.
  • The GRUB knows about the filesystem (the older Linux loader LILO didn’t understand the filesystem).
  • The Grub configuration file is /boot/grub/grub.conf (/etc/grub.conf is a link to this). The following is a sample grub—Conf of CentOS.
  • #boot=/dev/sda
    default=0
    timeout=5
    splashimage=(hd0,0)/boot/grub/splash.xpm.gz
    hiddenmenu
    title CentOS (2.6.18-194.el5PAE)
    root (hd0,0)
    kernel /boot/vmlinuz-2.6.18-194.el5PAE ro root=LABEL=/
    initrd /boot/initrd-2.6.18-194.el5PAE.img
  • As you notice from the above info, it contains the Kernel and initrd image.
  • So, in simple terms, GRUB loads and executes Kernel and initrd images.

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 the Kernel as a temporary root file system until the Kernel is booted and the natural root file system is mounted. It also contains necessary drivers compiled inside, which helps it to access the hard drive partitions and other hardware.

5. Init

    • Looks at the /etc/inittab file to decide the Linux run level.
  • Following are the available run levels
    • 0 – halt
    • 1 – Single user mode
    • 2 – Multiuser, without NFS
    • 3 – Full multiuser mode
    • 4 – unused
    • 5 – X11
    6 – reboot
  • Init identifies the default init level from /etc/inittab and uses that to load all appropriate programs.
  • Execute ‘grep init-default /etc/initial on your system to identify the default run level.
  • If you want to get into trouble, you can set the default run level to 0 or 6. Since you know what 0 and 6 mean, you probably might not do that.
  • Typically you would set the default run level to either 3 or 5.

6. Runlevel programs

  • When the Linux system booms up, you might see various services getting started. For example, it might say, “starting sendmail …. OK”. Those are the run-level programs executed from the run-level directory as defined by your run level.
  • Depending on your default init level setting, the system will execute the programs from one of the following directories.
  • 0 Run level – /etc/rc.d/rc0.d/
    1 Run level – /etc/rc.d/rc1.d/
    2 Run level – /etc/rc.d/rc2.d/
    3 Run level – /etc/rc.d/rc3.d/
    4 Run level – /etc/rc.d/rc4.d/
    5 Run level – /etc/rc.d/rc5.d/
    6 Run level – /etc/rc.d/rc6.d/

  • Symbolic links are also available for these directories under /etc. Directly. So, /etc/rc0.d is linked to /etc/rc.d/rc0.d.
  • Under the /etc/rc.d/rc*.d/ directories, you would see programs that start with S and K.
  • Programs that start with S are used during startup. S for a startup.
  • Programs starting with K are used during shutdown. K for a kill.
  • There are numbers right next to S and K in the program names. Those are the sequence number in which the programs should be started or killed.
  • For example, S12syslog is to start the Syslog daemon, which has the sequence number 12. S80sendmail is to create the sendmail daemon, which has the sequence number 80. So, the Syslog program will be started before sendmail.

 

Features of the Linux Boot Process

The Linux boot process ensures that the system is initialized and configured correctly before the user can access it. The boot process is highly customizable, allowing users to modify the boot parameters and define their runlevels. The Linux boot process is also modular, allowing kernel modules and system services to be added or removed.

Advantages of the Linux Boot Process

The Linux boot process has several advantages:

  1. It is highly configurable, allowing the user to customize the boot parameters and define their runlevels.
  2. The Linux boot process is modular, allowing for the addition or removal of kernel modules and system services.
  3. The Linux boot process is fast and efficient, allowing for quick boot times.

Disadvantages of the Linux Boot Process

The Linux boot process has a few drawbacks:

  1. The Linux boot process can be complex and challenging to understand for beginners.
  2. The Linux boot process requires specific technical knowledge to modify and customize.
  3. The Linux boot process can be slow on older hardware.

Alternative Options Linux Boot Process

There are several alternative options available for the Linux boot process. One of the most popular alternative options is the Systemd init system. Systemd is a current initialization system that aims to be quicker and more effective than the conventional SysVinit initialization system. Systemd is highly customizable and supports parallel startup of system services, which can significantly improve boot times.

Another alternative option is the Upstart init system, designed to be more lightweight and faster than SysVinit. Upstart is highly configurable and supports the event-based startup of system services.

Culmination

The boot process of Linux is a vital aspect of the operating system. It guarantees the system is initialized and configured accurately before the user can use it. The Linux boot process is highly customizable and modular, allowing kernel modules and system services to be added or removed. While the Linux boot process can be complex and challenging to understand for beginners, it is highly configurable and efficient, allowing for quick boot times. Alternative options, such as Systemd and Upstart, offer faster and more efficient boot times, making them attractive for users who prioritize speed and efficiency. The decision on which boot process to use will ultimately rely on the user’s specific requirements and preferences.

Install vs. code on fedora

FAQ

The Linux boot process is the process that occurs when a computer running Linux is turned on. It involves several stages that initialize and configure the system before the operating system is loaded.

 The six stages of the Linux boot process are:

  1. BIOS/UEFI: The computer’s firmware (BIOS or UEFI) initializes the hardware and performs a Power-On Self Test (POST) to ensure that the hardware is functioning properly.
  2. Bootloader: The bootloader is responsible for loading the Linux kernel into memory. The bootloader presents a boot menu (if configured) and then loads the selected kernel.
  3. Kernel initialization: The Linux kernel initializes the hardware and sets up the system. This involves detecting and configuring devices, loading device drivers, and setting up memory management.
  4. Initramfs: Initramfs (initial RAM filesystem) is a temporary filesystem that is used to load kernel modules and other utilities required to mount the root filesystem.
  5. Root filesystem: The root filesystem is mounted, and the system services are started. The root filesystem contains all the files required to run the operating system and the applications installed on it.
  6. User space: Once the root filesystem is mounted and the system services are started, the system is ready for user interaction. The login prompt is displayed, and users can log in and start using the system.

The purpose of the BIOS/UEFI stage is to initialize the hardware and perform a Power-On Self Test (POST) to ensure that the hardware is functioning properly. This stage is performed by the computer’s firmware before the bootloader is loaded.

The purpose of the bootloader stage is to load the Linux kernel into memory. The bootloader is responsible for presenting a boot menu (if configured) and then loading the selected kernel.

The purpose of the initramfs stage is to load kernel modules and other utilities required to mount the root filesystem. Initramfs is a temporary filesystem that is used before the root filesystem is mounted.

The purpose of the initramfs stage is to load kernel modules and other utilities required to mount the root filesystem. Initramfs is a temporary filesystem that is used before the root filesystem is mounted.

The purpose of the root filesystem stage is to mount the root filesystem and start the system services. The root filesystem contains all the files required to run the operating system and the applications installed on it.

The purpose of the user space stage is to provide user interaction. Once the root filesystem is mounted and the system services are started, the login prompt is displayed, and users can log in and start using the system.

Make a Comment
Share on
Facebook
Twitter
LinkedIn
Print
VPSie Cloud service

Fast and Secure Cloud VPS Service

Try FREE
For a month

The First 1 orders gets free discount today! Try Sign up on VPSie to get a chance to get the discount.