Linux Boot Process: Kernel Boot Process and Errors

Once we have installed a Linux operating system (Ubuntu, Debian, Mint, etc.), to use it we only have to press the power button of the PC and wait for the operating system to load. Just like any other operating system, like Windows. However, the boot process is quite a complex process, and it is also divided into several stages, each essential for our distro to start successfully. Therefore, if we know this startup process, it will be quite easy to identify and solve any possible problem that we may face.

There are some Linux distros that are configured so that the boot process, boot, is in verbose mode, that is, showing on the screen all the commands that are being executed. Although it is true that most, especially the “easy” distros, have a splash on the screen that prevents us from seeing it (although we can always show it by pressing Esc to control the process).

Linux Boot Process: Kernel Boot Process and Errors

However, both in text mode and with the static image on the screen, the startup process is the same. And since we press the power button until we can see the desktop we go through several phases that we will detail below.

BIOS / UEFI phase

This phase is the same for all operating systems. This small system, or firmware, is stored on a chip on the motherboard and is responsible for verifying that all the components of the PC are connected and working correctly. To do this, perform a POST (Power-On Self Test) , verify that the necessary peripherals are connected to continue (especially keyboard), and locate the unit that we have configured as “boot”, where the bootloader will be to continue with the operating system load.

Some of the errors that we can find at this point are the following, and most of the time they are related to the hardware directly (especially with hard drives), so they are solved by checking that the peripherals are well connected, or by resetting the BIOS to factory settings:

  • MBR corruption.
  • Corrupt partition table.
  • PBR corruption.
  • Bootsector corruption.
  • Corrupt disk.
  • Bootmgr corruption.

Boot Loader phase

In this phase, the computer will try to access the Master Boot Record (MBR) or the Guided Partition Table (GPT) of the hard disk, depending on the BIOS or UEFI configuration. If this partition is not found, we will directly see a message on the computer indicating that the operating system is not found. In that case, we would have to check the BIOS or UEFI boot configuration, and if necessary even reinstall the OS so that the boot will be regenerated.

If this partition is found, then the next thing we’ll see will be the Linux boot menu, also known as “GRUB” (although there may be other bootloaders, like LILO). Here we will see all the operating systems that are installed on the PC, as well as other boot loader entries (different kernel, recovery options, RAM memory analyzer, etc.).

GRUB con Ubuntu y Windows 10

We will choose the entry we want to boot (Ubuntu, for example, to continue with the Linux boot) and in the next stage the loading of the Kernel itself will begin.

The errors that we can find at this point are corrupt entries within GRUB . And the way to solve it is using a recovery disk (or a Linux Live distro that we can load from RAM) to repair the GRUB and make the entries point to the corresponding hard drives or partitions.

Linux Kernel startup phase

Now comes the most important boot phase: the Linux Kernel phase. Regardless of the distro we use, all of them will use a more or less personalized version of the original kernel of this operating system. For reasons of space and optimization, the Kernel is kept compressed to disk, so the first thing to do is unzip it in memory in order to continue.

Boot Linux 1

The next step will be the initialization of all the components. To do this, most distros use a daemon controller called systemd (although some use alternatives such as init.d). What is done in this step is to launch all the processes and services that are part of the system and are essential for its proper functioning. All of these processes allow hardware to function and all components of the operating system to be synchronized, especially memory and disks. These services will continue to function after the boot process, and will be closed at the time of the system shutdown.

In addition to the essential Linux processes and services, other personalized services can also be loaded (for example, a server that we have mounted and configured, such as an SSH or an FTP).

Unless we have made modifications to the system ourselves, it is rare to encounter problems at this point. Booting the system with Systemd is usually a fully automatic process and requires no intervention on our part. Also, if any daemon cannot be loaded, it will simply mark it as an error and move on to the next one. What can happen is that some daemons take many seconds to load . And then what we should do is check at what point Systemd hangs and try to solve the problem by disabling the service, configuring it correctly or updating the system.

Final phase of Linux boot

At this point, our distro will be ready. This is when the “runlevel” phase enters which will indicate with a number the type of operation of the operating system according to the services that have been loaded correctly:

  • 0 – Halt. Critical system error.
  • 1 – Single user mode.
  • 2 – Multi-user mode without network access.
  • 3 – Terminal multi-user mode.
  • 4 – User defined mode.
  • 5 – Multi-user mode with graphic environment. It is the desired mode and in which it will try to start by default always
  • 6 – Requires restarting the computer.

Assuming that we have obtained a “5” in the runlevel, then we can already see the login screen of our Linux distro, and we can log in. Once logged in, we will have the desktop at our fingertips, and we can start working with the computer freely.

Escritorio Ubuntu

We can change the value of runlevel by executing in a terminal “telinit” followed by the value we want. For example, a value “0” would force a PC shutdown, while a value “1” would only allow us to use Linux in single-user mode.

We can also see the time it took for our distro to load with the command “systemd-analyze”:

systemd-analyze