Deep Dive into Linux Boot Process: BIOS, MBR, GRUB, initrd, and System Initialization
This article provides a comprehensive, step‑by‑step explanation of the Linux boot sequence, covering BIOS self‑test, MBR structure, GRUB stages, initrd/initramfs handling, and the final system initialization scripts that bring a Linux system to a usable state.
BIOS Self‑Test
The BIOS (Basic Input/Output System) resides in ROM (now Flash EPROM) and performs a Power‑On Self Test (POST) to verify critical hardware such as CPU, memory, and I/O devices. After POST, BIOS provides Runtime services and hands control to the boot device.
System Boot (MBR)
The Master Boot Record (MBR) occupies the first 512 bytes of a disk and contains three parts: the bootloader code, the Disk Partition Table (DPT), and the boot signature (55AA). The bootloader reads the first sector of the selected boot device and transfers execution to it.
GRUB Stages
GRUB typically uses two stages. Stage 1 resides in the MBR and loads the next sector (often called stage1.5) into memory at 0x7C00. Stage 2 (or stage1.5) is then loaded, which can understand file systems and loads the kernel image and initrd.
Stage 1 loads the first three sectors (head 0, cylinder 0, sectors 0‑2) into memory, then passes control to stage 2 located at sector 3 if present. Stage 2 may be placed at 0x820 (for pure stage 2) or 0x2200 (for stage 1.5) depending on the configuration.
Kernel Boot
After GRUB loads the kernel image, the kernel initializes hardware, mounts the initial RAM disk (initrd) if specified, and then proceeds to the real root filesystem. Drivers needed early in boot are either built into the kernel or provided as modules in the initrd.
initrd vs. initramfs
initrd is an ISO‑9660 image loaded by the bootloader before the kernel starts; the kernel runs an init script from it, then switches to the real root filesystem.
initramfs (introduced in kernel 2.5) embeds a cpio archive directly in the kernel image. The kernel extracts it into a temporary rootfs, runs its init, and then pivots to the real root.
System Initialization
Once the real root filesystem is mounted, the /sbin/init process becomes the parent of all other processes. It reads /etc/inittab and executes the system initialization script /etc/rc.d/rc.sysinit, which performs tasks such as network configuration, loading kernel modules, setting the hostname, configuring SELinux, mounting filesystems, and starting services according to runlevel scripts in /etc/rc.d/rc*.d.
After rc.sysinit finishes, the /etc/rc.d/rc script runs the appropriate start‑up scripts (S*) and stop scripts (K*) for the selected runlevel, then launches the login terminals or X‑Window server.
Conclusion
The Linux boot process is a layered sequence: BIOS POST → MBR → GRUB stages → kernel image → initrd/initramfs → /sbin/init → system services. Understanding each stage helps diagnose boot failures and customize the startup flow.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
