일. 8월 3rd, 2025

For anyone exploring Linux, understanding its boot sequence demystifies how your system transitions from a powered-off state to a fully functional OS. Here’s a detailed breakdown:

🔌 1. Power-On & Firmware Initialization

  • BIOS (Legacy):
    • The Basic Input/Output System performs hardware checks (POST – Power-On Self-Test).
    • Searches storage devices for a boot sector (first 512 bytes) with a boot signature (0x55AA).
  • UEFI (Modern):
    • Replaces BIOS with a standardized interface.
    • Reads the EFI System Partition (ESP) to locate bootloaders (e.g., /EFI/ubuntu/grubx64.efi).

🚀 2. Bootloader Stage

  • Role: Loads the Linux kernel into memory.
  • Common Tools: GRUB (GRand Unified Bootloader), LILO, or systemd-boot.
    GRUB2 workflow:
    1. Loads `/boot/grub/grub.cfg`.
    2. Displays OS selection menu.
    3. Loads the kernel (vmlinuz) and initramfs into RAM.
  • initramfs (Initial RAM Filesystem):
    • A temporary root filesystem containing drivers/modules (e.g., for disk encryption or RAID).
    • Essential for mounting the real root (/) filesystem later.

⚙️ 3. Kernel Initialization

  • The decompressed kernel (vmlinuz) takes over:
    1. Initializes CPU, memory, and hardware.
    2. Mounts the root filesystem using parameters from initramfs.
    3. Looks for init (or systemd) at /sbin/init.
    4. Releases unused initramfs memory.

🌀 4. Init Process – PID 1

  • The first user-space process (/sbin/init) spawns all other processes.
  • Traditional (SysVinit):
    • Uses scripts in /etc/init.d/ and symbolic links in /etc/rcX.d/ (where X = runlevel).
  • Modern (systemd):
    • Replaces runlevels with targets (e.g., graphical.target = GUI mode).
    • Manages services in parallel for faster booting.

🎯 5. Runlevels / Targets & Services

  • Runlevels (SysVinit):
    • = Halt | 1 = Single-user (maintenance) | 3 = Multi-user (CLI) | 5 = Graphical.
  • Targets (systemd):
    • multi-user.target → CLI mode | graphical.target → Desktop environment.
  • Service Activation:
    • Critical services (networking, SSH, display managers) start based on the target.
    • Logs are captured by systemd-journald.

🏁 6. Login Prompt

  • A getty process launches terminal logins (TTY1–6).
  • Display managers (e.g., GDM, LightDM) start for graphical logins.

📊 Boot Process Flowchart

Power → BIOS/UEFI → Bootloader → Kernel → initramfs → Kernel mounts root → /sbin/init (PID 1) → Targets/Runlevels → Services → Login  

💡 Key Troubleshooting Commands

  • dmesg – Kernel boot messages.
  • systemd-analyze blame – Check slow booting services.
  • journalctl -b – View boot logs.

Understanding these phases helps diagnose boot failures (e.g., kernel panics, missing init) and optimize startup. Welcome to the heart of Linux! 🐧

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다