Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux 開機流程核心知識:BIOS → MBR → Bootloader → vmlinux/initrd 兩階段解析

編輯:Linux 教學

PC 從硬碟啟動 Linux 分兩階段:

階段一:BIOS 自檢與 MBR 載入

  • BIOS (固化於主板) 執行 POST,尋找可啟動裝置。
  • 讀取 MBR (第 0 柱面、第 0 磁頭、第 1 扇區),固定 512 Bytes:
     前 446 Bytes:Bootstrap 程式碼
     中間 64 Bytes:分區表 (DPT)
     最後 2 Bytes:結束標記 (0x55AA)
  • Bootstrap 任務:尋找開機參數、載入核心映像至記憶體、傳遞參數、移交 CPU 控制權給核心。

常見 Bootloader

  • LILO:較老舊,配置檔 /etc/lilo.conf,需重新執行 lilo 寫入 MBR。
  • GRUB (Legacy/2):模組化、支援多檔案系統、動態選單、可命令列介面手動啟動。

關鍵映像檔

  • vmlinux:ELF/COFF/a.out 格式靜態連結執行檔,含完整符號表,供核心除錯用;非直接可啟動,需加入 multiboot header、bootsector、setup routines。
  • initrd (initial ramdisk):壓縮 (gzip) 的循環掛載檔案系統,包含核心啟動早期所需模組 (如 SCSI/RAID/檔案系統驅動),由 Bootloader 載入記憶體並掛載為根檔案系統,隨後 pivot_root 切換至真實根分區。早期常放於軟碟。

映像檔關係圖譜

vmlinux (ELF 完整符號)
   ↓ objcopy 移除註釋段,保留 .text + .data
Image
   ↓ gzip 壓縮
zImage
   ↓ 加上 0x40 bytes U-Boot header
uImage (供 U-Boot 直接啟動)

理解此流程有助於嵌入式開發、核心除錯與開機故障排查。

Copyright © Windows教程網 All Rights Reserved