A Basic Guide to Linux Boot Process

Every time you power on your Linux PC, it goes through a series of stages before finally displaying a login screen that prompts for your username or password. There are 4 distinct stages that every Linux distribution goes through in a typical boot-up process.

User Login Prompt
User Login Prompt

In this guide, we will highlight the various steps taken by the Linux OS from the time it is powered on to the time you log in. Kindly note that this guide only takes into consideration the GRUB2 bootloader and systemd init as they are currently in use by a vast majority of modern Linux distributions.

The booting process takes the following 4 steps that we will discuss in greater detail:

  • BIOS Integrity check (POST)
  • Loading of the Boot loader (GRUB2)
  • Kernel initialization
  • Starting systemd, the parent of all processes

1. The BIOS Integrity Check (POST)

The boot process is usually initialized when a user presses the power-on button – if the PC was already shut down – or reboots the system using either the GUI or on the command line.

When the Linux system powers up, the BIOS (Basic Input Output System) kicks in and performs a Power On Self Test (POST). This is an integrity check that performs a plethora of diagnostic checks.

The POST probes the hardware operability of components such as the HDD or SSD, Keyboard, RAM, USB ports, and any other piece of hardware. If some hardware device is not detected, or if there’s a malfunction in any of the devices such as a corrupt HDD or SSD, an error message is splashed on the screen prompting your intervention.

In some cases, a beeping sound will go off especially in the event of a missing RAM module. However, if the expected hardware is present and functioning as expected, the booting process proceeds to the next stage.

2. The Bootloader (GRUB2)

Once the POST is complete and the coast is clear, the BIOS probes the MBR (Master Boot Record) for the bootloader and disk partitioning information.

The MBR is a 512-byte code that is located on the first sector of the hard drive which is usually /dev/sda or /dev/hda depending on your hard drive architecture. Note, however, that sometimes the MBR can be located on a Live USB or DVD installation of Linux.

There are 3 main types of bootloaders in Linux: LILO, GRUB, and GRUB2. The GRUB2 bootloader is the latest and primary bootloader in modern Linux distributions and informs our decision to leave out the other two which have become antiquated with the passage of time.

GRUB2 stands for GRand Unified Bootloader version 2. Once the BIOS locates the grub2 bootloader, it executes and loads it onto the main memory (RAM).

The grub2 menu allows you to do a couple of things. It allows you to select the Linux kernel version that you’d want to use. If you have been upgrading your system a couple of times, you might see different kernel versions listed. Additionally, it gives you the ability to edit some kernel parameters by pressing a combination of keyboard keys.

Select Kernel Version
Select Kernel Version

Also, in a dual-boot setup where you have multiple OS installations, the grub menu allows you to select which OS to boot into. The grub2 configuration file is the /boot/grub2/grub2.cfg file. GRUB’s main objective is to load the Linux kernel onto the main memory.

3. Kernel Initialization

The kernel is the core of any Linux system. It interfaces the PC’s hardware with the underlying processes. The kernel controls all the processes on your Linux system. Once the selected Linux kernel is loaded by the bootloader, it must self extract from its compressed version before undertaking any task. Upon self-extracting, the selected kernel mounts the root file system and initializes the /sbin/init program commonly referred to as init.

Kernel Initialization Process
Kernel Initialization Process

Init is always the first program to be executed and is assigned the process ID or PID of 1. It’s the init process that spawns various daemons & mounts all partitions that are specified in the /etc/fstab file.

The kernel then mounts the initial RAM disk (initrd) which is a temporary root filesystem until the real root filesystem is mounted. All kernels are located in the /boot directory together with the initial RAM disk image.

4.Starting Systemd

The kernel finally loads Systemd, which is the replacement of the old SysV init. Systemd is the mother of all Linux processes and manages among other things mounting of file systems, starting and stopping services to mention just a few.

Systemd uses the /etc/systemd/system/default.target file to determine the state or target that the Linux system should boot into.

  • For a desktop workstation (with a GUI) the default target value is 5 which is the equivalent of run level 5 for the old SystemV init.
  • For a server, the default target is multi-user.target which corresponds to run level 3 in SysV init.

Here’s a breakdown of the systemd targets:

  • poweroff.target (runlevel 0): Poweroff or Shutdown the system.
  • rescue.target (runlevel 1): launches a rescue shell session.
  • multi-user.target (runlevel 2,3,4): Configures the system to a non-graphical (console) multi-user system.
  • graphical.target (runlevel 5): Set the system to use a graphical multi-user interface with network services.
  • reboot.target (runlevel 6): reboots the system.

To check the current target on your system, run the command:

$ systemctl get-default
Check Run Level
Check Run Level

You can switch from one target to another by running the following command on the terminal:

$ init runlevel-value

For example, init 3 configures the system to a non-graphical state.

The init 6 command reboots your system and init 0 powers off the system. Be sure to invoke sudo command when you want to switch to these two targets.

The booting process ends once systemd loads all the daemons and sets the target or run level value. It’s at this point you are prompted for your username and password upon which you gain entry to your Linux system.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

45 thoughts on “A Basic Guide to Linux Boot Process”

  1. Of course Step #4 is valid only for systemd. While the runlevels remain the same across all init programs, each init (S6, runit, sysVinit, etc) has its own steps in starting a system.

    BTW – systemd is no longer just an init program. It is slowly becoming the control program for the distros that use it as more and more functionality is grafted unto it. systemd violates the basic Unix/Linux/BSD principle of doing one thing and doing it well. It is an octopus that does many jobs barely adequately.

    Reply
  2. Hi. This is a great article with valuable information, but the poor grammar and poor organization makes it difficult to understand. I think it would help if you used Grammarly or another app to help you improve the clarity and readability of the article.

    Reply
    • Over the years employing someone with the knowledge of idiomatic English has been suggested quite a few times. The site owners and/or managers do not see idiomatic writing and translation as a priority as long as the information is there.

      Reply
  3. I am installing the internet connections on my hp dv9000 laptop and am having trouble with the internet connections. In IPv6 there are three boxes that show the: Address, Prefix, and Gateway.

    So far the “Prefix” area will not accept anything I put in that box. If IPv4 and IPv6 are set to automatic, nothing works! Broadcom b43 is used on wireless, etc. and my computer finally acknowledges that it is installed but states that there are no extensions! Can anyone help me with these two problems?

    Reply
  4. I need some help here. I updated Ubuntu 18.04. After doing that the option to restart was given, I did but now I can’t get past the Setup/Boot Options screen. Is there anything I can do to get past this screen?

    Reply
  5. Hi, you are providing valuable information. But the language is poor and so often, it’s not clear what you mean. You need to improve the quality of your content. Otherwise, despite all the information you are providing, it won’t be of much use to most people.

    Reply

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.