Essential Interview Skills (Often Overlooked): Detailed Explanation of the Linux Boot Process

Essential Interview Skills (Often Overlooked): Detailed Explanation of the Linux Boot Process

The Linux boot process is one of the core aspects of the operating system, involving multiple stages such as hardware initialization → boot loading → kernel loading → user space initialization. Understanding the boot process not only aids in troubleshooting (e.g., system not booting, getting stuck at a certain stage) but also helps operations personnel optimize performance and security.

🖥️ 1. BIOS/UEFI Initialization

  • BIOS (Basic Input/Output System) or UEFI (Unified Extensible Firmware Interface) is the first code executed after the computer is powered on.

  • Functions:

  1. POST (Power-On Self Test): Checks if hardware such as CPU, memory, hard disk, and graphics card are functioning properly.

  2. Load boot device information: Determines where to load the operating system (hard disk/CD/USB/network) based on the boot order.

  3. Hand over to the boot loader: Such as MBR (Master Boot Record) or the boot program in the EFI partition.

👉 If an error occurs here, you will typically see “No bootable device” or “Operating System not found”.

💽 2. MBR / EFI Stage

The process varies slightly depending on the boot mode used by the system:

  • MBR (Traditional BIOS Boot)

    • First stage of the boot loader.

    • Disk partition table.

    • The first 512 bytes of the hard disk store the Master Boot Record (MBR).

    • MBR contains:

    • Common Boot Loaders: GRUB, LILO.

  • UEFI Boot

    • <span><span>EFI/BOOT/BOOTX64.EFI</span></span>

    • <span><span>EFI/GRUB/grubx64.efi</span></span>

    • There is an EFI System Partition (ESP) on the hard disk, formatted as FAT32.

    • ESP stores the boot files for various operating systems, such as:

👉 Most modern Linux systems use the UEFI + GRUB2 method.

🌀 3. Boot Loader Stage (Using GRUB2 as an Example)

GRUB (GRand Unified Bootloader) is the most common boot loader for Linux.

Its main functions are:

  1. Provide a boot menu: Users can select different kernel versions or operating systems.

  2. Load the kernel: Loads the Linux kernel image file (<span><span>vmlinuz</span></span>) into memory.

  3. Pass initrd/initramfs: Provides a temporary root filesystem to facilitate mounting the real root filesystem during kernel startup.

👉 The GRUB2 configuration file is usually located at:

  • <span><span>/boot/grub2/grub.cfg</span></span> (BIOS mode)

  • <span><span>/boot/efi/EFI/centos/grub.cfg</span></span> (UEFI mode)

🐧 4. Kernel Loading Stage

Once GRUB loads the kernel into memory, the Linux kernel begins execution.

The main steps of kernel startup are:

  1. Decompress the kernel image (vmlinuz).

  2. Mount initramfs (temporary root filesystem).

  3. Driver initialization (e.g., disk controllers, USB, network, etc.).

  4. Mount the real root filesystem (e.g., <span><span>/dev/sda2</span></span>).

  5. Execute the first user space process:<span><span>/sbin/init</span></span>.

👉 If the kernel cannot find the root filesystem, it will report an error <span><span>Kernel panic – not syncing: VFS: Unable to mount root fs</span></span>.

⚙️ 5. init/systemd Stage

After the Linux kernel starts, it runs the first user space process:

  • Traditional systems use SysV init, with configuration file <span><span>/etc/inittab</span></span>.

  • Modern Linux distributions use systemd (PID = 1), which is faster and more flexible than init.

The responsibilities of systemd are:

  1. Mount filesystems.

  2. Start necessary system services (e.g., network, logging, SSH).

  3. Enter the default run level (Target):

  • <span><span>graphical.target</span></span> → Graphical interface

  • <span><span>multi-user.target</span></span> → Command line

👉 systemd configuration directories:

  • <span><span>/etc/systemd/system/</span></span>

  • <span><span>/usr/lib/systemd/system/</span></span>

👤 6. User Login Stage

Once all system services are started, Linux enters the login interface:

  • Command line mode: Provides TTY login through <span><span>getty</span></span> or <span><span>systemd-logind</span></span>.

  • Graphical interface: Provided by display managers such as GDM, LightDM.

Upon successful login, the system will:

  1. Read user environment configuration files (e.g., <span><span>.bashrc</span></span>, <span><span>.profile</span></span>).

  2. Start the user Shell (e.g., bash, zsh).

At this point, the Linux boot process is officially complete ✅.

🔎 Summary (6 Major Stages of Linux Boot)

  1. BIOS/UEFI: Hardware initialization, selecting the boot device.

  2. MBR/EFI: Load Boot Loader (e.g., GRUB2).

  3. Boot Loader: Load kernel and initramfs.

  4. Kernel Stage: Driver initialization, mount root filesystem.

  5. init/systemd: Start system services, enter run level.

  6. User Login: Load user environment, enter Shell or desktop.

📌 Boot process diagram:

BIOS/UEFI → MBR/EFI → Boot Loader (GRUB) → Kernel → systemd/init → User Login


Leave a Comment