Unraveling the Linux Boot Process: From BIOS to System Init
This article provides a step‑by‑step, in‑depth walkthrough of the Linux boot sequence on CentOS 6, covering BIOS POST, MBR and GRUB stages, kernel loading, initrd/initramfs handling, and the init system’s run‑level scripts that finally bring the system to a usable state.
After gaining a basic understanding of Linux, the author dives into the deeper layers of the operating system, focusing on the complete boot sequence of a CentOS 6.0 machine running kernel 2.6.32.
BIOS Self‑Test (POST)
The BIOS, stored in flash EPROM, performs a Power‑On Self Test to verify critical hardware such as CPU, memory, graphics, and I/O devices. If any component fails (e.g., loose RAM), the boot halts with an error.
After POST, the BIOS reads the first sector of the boot device (the Master Boot Record, 512 bytes) and transfers execution to the code found there.
System Bootloader (MBR and GRUB)
The MBR contains three parts: the bootloader code, the disk partition table (DPT), and the boot signature (55AA). Common bootloaders like LILO or GRUB install their first stage directly in the MBR.
GRUB’s boot process is split into two (or three) stages:
Stage 1 – 446 bytes stored in the MBR; BIOS loads it at address 0x7C00 and it reads sector 0:2 (the start of stage 2) from the disk.
Stage 1.5 (optional) – Provides filesystem awareness, allowing the next stage to be located on a filesystem.
Stage 2 – Loaded into memory (0x8000 for stage 2, 0x2200 for stage 1.5) and contains the full GRUB code that reads /boot/grub/grub.conf and loads the kernel image.
Kernel Loading
Stage 2 parses /boot/grub/grub.conf, loads the selected kernel image into memory, and transfers control to the kernel. The kernel then initializes hardware devices (CPU, I/O, storage) and proceeds to load drivers.
Drivers are either built into the kernel image or provided as modules in an initrd (initial RAM disk).
Initrd and Initramfs
The initrd is a temporary root filesystem loaded by the bootloader before the real root filesystem is mounted. It contains a minimal set of drivers and an init script that prepares the real root.
Since kernel 2.5, initramfs replaces initrd: a cpio archive embedded in the kernel image that is unpacked into rootfs, allowing a smaller, more customizable early userspace.
System Initialization (init)
After the kernel hands over to the initramfs init script, the script loads additional drivers, creates the root device, mounts the real root filesystem read‑only, and finally executes /sbin/init, the first user‑space process. /sbin/init reads /etc/inittab and runs the system initialization scripts: /etc/rc.d/rc.sysinit – basic system setup, mounting filesystems, configuring network, loading modules, setting SELinux, etc. /etc/rc.d/rc*.d – run‑level specific start (S) and kill (K) scripts, linked from /etc/init.d. /etc/rc.d/rc.local – user‑defined commands executed at the end of the boot sequence.
The run‑level scripts perform tasks such as configuring the clock, loading LVM/RAID, setting up quotas, and starting essential services. After all scripts finish, the system presents login prompts on virtual terminals (tty1‑tty6) or starts the X‑Window manager.
Conclusion
The article concludes that the described steps fully explain the Linux boot process on the examined system, and invites readers to explore further details in future posts.
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.
