System Boot Process in Operating Systems

System Boot Process in Operating Systems

1. Overview of the System Boot Process

The system boot process refers to the entire sequence from pressing the power button to the operating system being fully loaded and running user programs. It involves key steps such as hardware initialization, bootloader execution, kernel loading and initialization. The following example uses the traditional BIOS boot process (modern UEFI boot differs slightly, but the core logic is similar).


2. Detailed Boot Steps

Step 1: Power-On Self-Test (POST)

  • Hardware Trigger: After power is applied, the CPU resets registers and points to a predefined physical address (e.g., 0xFFFF0 on x86 architecture), which stores the BIOS program.
  • POST Tasks:
    • Detects whether critical hardware (memory, hard disk, keyboard, etc.) is functioning correctly.
    • Initializes hardware devices (e.g., graphics card, disk controller).
  • Error Handling: If hardware failure occurs, the boot process halts with beep codes or on-screen error messages.

Step 2: BIOS Boot

  • Reading Boot Device Order: BIOS searches for bootable devices according to a preset order (e.g., USB → Hard Disk → Network).
  • Checking the Boot Sector: Reads the first sector of the device (Master Boot Record - MBR, 512 bytes) and verifies the ending magic number 0x55AA.
  • Loading the MBR: Copies the MBR content to memory address 0x7C00 and jumps to execute it.

Step 3: Bootloader Stage

  • MBR Structure:
    • First 446 bytes: Boot code (e.g., GRUB Stage 1).
    • Next 64 bytes: Partition table (4 primary partition entries).
    • Last 2 bytes: Magic number 0x55AA.
  • Limitations and Extensions: The MBR size is limited. Modern bootloaders (like GRUB) work in multiple stages:
    • Stage 1: Loads additional sectors located after the MBR (e.g., GRUB's Stage 1.5).
    • Stage 2: Reads the filesystem and loads the kernel image and initial RAM disk (initramfs).

Step 4: Kernel Loading and Initialization

  • Decompression and Mapping: The kernel is usually compressed (e.g., zImage). The bootloader decompresses it into memory and jumps to its entry point.
  • Kernel Initialization:
    • Initializes memory management, interrupt controller, process scheduler.
    • Mounts the root filesystem (may require initramfs to provide temporary drivers).
  • Launching the First User Process: The kernel executes /sbin/init (or an initialization system like systemd) to complete user-space initialization.

Step 5: User Space Initialization

  • init Process:
    • Reads configuration files (e.g., /etc/inittab or systemd units).
    • Starts system services (network, logging, etc.) and the login manager.
  • Final State: Presents a login screen or command-line terminal, awaiting user interaction.

3. Key Technologies and Evolution

  • UEFI Replacing BIOS:
    • Directly reads the boot program from a FAT partition (e.g., /EFI/BOOT/BOOTX64.EFI), eliminating the need for MBR.
    • Supports Secure Boot for digital signature verification.
  • Role of Initramfs:
    • Provides a temporary root filesystem during the early kernel boot stage, containing drivers needed to load the real root filesystem (e.g., for RAID, LVM).
    • Prevents kernel bloat by enabling modular driver loading.

4. Troubleshooting Examples

  • Common Issues:
    • Missing boot sector: Error message "No bootable device".
    • Corrupted kernel: Message "Kernel panic".
    • init process failure: System hangs during boot stage.
  • Repair Methods: Use a Live CD to reinstall the bootloader or repair the filesystem.

Through the above steps, the operating system completes the full chain from hardware initialization to user services, ensuring a reliable system boot.