Linux Boot Process
The Linux boot process involves several stages, each responsible for initializing and configuring different parts of the system to eventually hand over control to the operating system. Hereβs a detailed explanation of each step:
BIOS/UEFI Initialization:
When the computer is powered on, the BIOS (Basic Input/Output System) or UEFI (Unified Extensible Firmware Interface) initializes the hardware components and performs a ππ¨π°ππ«-ππ§ πππ₯π πππ¬π (ππππ) to ensure all necessary hardware is functioning correctly.
BIOS/UEFI locates and initializes the bootable device (e.g., hard drive, SSD).
Bootloader Stage 1 (MBR/GPT):
The BIOS/UEFI reads the first sector of the bootable device, known as the Master Boot Record (MBR) for BIOS or the GUID Partition Table (GPT) for UEFI.
The MBR contains the bootloader code (typically GRUB or LILO), which is responsible for loading the second stage of the bootloader. For GPT, UEFI directly points to the bootloader file (e.g., EFI partition).
Bootloader Stage 2 (GRUB):
The second stage of the bootloader (e.g., GRUB - Grand Unified Bootloader) presents a menu to the user to select the operating system to boot.
GRUB loads the selected kernel image into memory along with the initial RAM disk (initrd/initramfs), which contains temporary root file system required during the initial boot.
Kernel Initialization:
The Linux kernel is decompressed and initialized. It sets up memory and hardware, mounts the initrd/initramfs, and loads necessary drivers.
The kernel then mounts the real root file system (specified in the bootloader configuration) and frees the initrd/initramfs from memory.
Init Process:
The kernel starts the initial process, often referred to as
init
(PID 1), which is the first user-space program.Depending on the system, this could be
sysvinit
,systemd
,upstart
, or another init system.
System Initialization:
The init process initializes system services and daemons according to its configuration (e.g.,
/etc/inittab
).This includes setting up networking, starting background services, mounting additional file systems, and other system initialization tasks.
User Login:
Once all the necessary services are started and the system is fully initialized, the init process spawns login prompts (TTYs) for user interaction.
The system is now ready for user logins and use.
Here's a chart outlining the Linux boot process:
ππππ π | πππ¬ππ«π’π©ππ’π¨π§ |
BIOS/UEFI | Power on triggers the Basic Input/Output System (BIOS) or Unified Extensible Firmware Interface (UEFI) firmware. It performs a Power-On Self Test (POST) to check system hardware and locates a bootable device. |
Boot Loader (GRUB) | BIOS/UEFI loads the boot loader, typically GRUB (Grand Unified Bootloader). GRUB identifies the kernel and any initial RAM disk (initrd/initramfs) needed. |
Kernel | The kernel, the core of the Linux operating system, is loaded into memory. It initializes core system functions like memory management, device drivers, and process management. |
Initrd/Initramfs | An initial RAM disk (initrd or initramfs) can be loaded alongside the kernel. It's a temporary filesystem containing essential drivers or modules needed for early hardware initialization. |
Init Process (systemd) | The kernel starts the init process, typically systemd in modern systems. Systemd manages services and brings the system up according to the configured runlevel or target. |
Runlevel/Target | Systemd activates services based on the designated runlevel or target (systemd). Common targets include multi-user (console), graphical (desktop environment), or single-user (rescue mode). |
Login Shell | After system services are brought up, a login shell is presented where you can log in as a user. |
Subscribe to my newsletter
Read articles from Arif Sadiq directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Arif Sadiq
Arif Sadiq
I am a Linux engineer with over a decade of experience since 2012. My career began as an Linux Engineer, then to IT Engineer and Data Center Engineer, managing both Windows and Linux servers. I have extensive experience in hosting, troubleshooting server issues, and managing server-related services. I am well-versed in cloud platforms like AWS and Azure. Currently, I am a DevOps enthusiast, eager to learn and grow my career in the DevOps field.