What is Linux Boot Process?

The Linux boot process is a fascinating journey that takes place every time you power on your system. In this guide, we’ll walk through the entire process step-by-step—from the moment you press the power button until you see the login prompt. We’ll cover which scripts run, which configuration files are read (and in what order), and how it all comes together. While the basics apply to most Linux distributions, some details might be specific to Red Hat-based systems.

An operating system (OS) is like the backstage crew of a theater production—it manages the computer’s resources, coordinates hardware like your keyboard and mouse, and provides a foundation for other software to run smoothly. In Linux, the boot process goes through six key stages to bring your system to life.

1. BIOS Initialization

The BIOS, or Basic Input/Output System, is a small but essential program built into your computer. It’s the first thing that kicks into action when you power on your machine. The BIOS performs a quick health check on your hardware, known as POST (Power-On Self-Test), to make sure everything’s working properly.

Once POST is complete, the BIOS searches for a device to boot from. You can customize the order it follows—like choosing whether it should check a USB drive, hard drive, CD/DVD, or even a network connection first.

When the BIOS finds a bootable device, it looks for a special area called the boot sector. This sector contains the instructions needed to start the operating system and get your computer up and running.

2. The Master Boot Record(MBR)

The Master Boot Record (MBR) is a small but essential part of your computer’s startup process. It’s located in the first sector of your bootable disk, usually something like /dev/sda or /dev/hda, depending on the hardware.

The MBR’s job is to find and launch the bootloader—commonly GRUB (GRand Unified Bootloader), or in much older systems, LILO. Without the MBR, your operating system wouldn’t know how to start.

3. GRUB

GRUB, or the GNU GRand Unified Bootloader, is the most common boot loader you’ll encounter on modern Linux systems. It’s the first thing you’ll see when your computer starts up — a simple menu that lets you choose how you want to boot your system.

If you have multiple kernel versions installed, you can use the arrow keys to pick the one you want to use. By default, GRUB automatically selects the latest kernel version.

When the GRUB menu appears, it will wait a few seconds to give you a chance to make a selection. If you don’t press anything, it will go ahead and load the default kernel.

The GRUB configuration file is usually found at /boot/grub/grub.conf or /etc/grub.conf on most systems.

4. Kernel

The kernel is like the brain of any operating system, including Linux. It has full control over everything happening on your computer.

When you turn on your system, the kernel selected by GRUB (the boot loader) kicks into action by mounting the root file system, which is specified in the grub.conf file. Next, it runs the /sbin/init program — the very first process that starts, and you can always recognize it by its process ID (PID) of 1.

At this stage, the kernel uses a temporary file system called Initial RAM Disk (initrd) to get things going until it can mount the actual file system.

5. Init

The init process is the first program that the kernel starts when your computer boots up. It acts as the parent of all other processes and always has a Process ID (PID) of 1. This process runs continuously until the system is shut down. Its job is to manage the overall state of the system. The configuration settings for the init process are stored in the /etc/inittab file, which plays a key role in the system’s startup process.

6. Runlevel programs

Depending on your Linux distribution, you might notice different services starting up during boot. For instance, you might see a message like “starting sendmail… OK.”

These services are called runlevel programs, and they are launched from specific directories based on the system’s current run level. Each of the six runlevels mentioned earlier has its own dedicated directory.

Let’s discuss about runlevels.

Run level 0 – /etc/rc0.d/
Run level 1 – /etc/rc1.d/
Run level 2  – /etc/rc2.d/
Run level 3  – /etc/rc3.d/
Run level 4 – /etc/rc4.d/
Run level 5 – /etc/rc5.d/
Run level 6 – /etc/rc6.d/

0: Halt or shutdown the system
1: Single user mode
2: Multi-user mode, without networking
3: Full multi user mode, with NFS (typical for servers)
4: Officially not defined; Unused
5: Full multi user with NFS and graphics (typical for desktops)
6: Reboot

Run level 0 is matched by poweroff.target (and runlevel0.target is a symbolic link to poweroff.target).

Run level 1 is matched by rescue.target (and runlevel1.target is a symbolic link to rescue.target).

Run level 3 is emulated by multi-user.target (and runlevel3.target is a symbolic link to multi-user.target).

Run level 5 is emulated by graphical.target (and runlevel5.target is a symbolic link to graphical.target).

Run level 6 is emulated by reboot.target (and runlevel6.target is a symbolic link to reboot.target).

The location of these directories can vary depending on the Linux distribution you’re using.

If you check out the different runlevel directories, you’ll notice programs that begin with either “S” or “K.” The “S” programs are for startup, meaning they run when the system boots up, while the “K” programs are for shutdown, running when the system is shutting down.

Leave a Reply

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