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 系統故障排查大全:從啟動流程到救援模式實戰

編輯:Linux 教學

本文系統整理 Linux 開機流程(BIOS → MBR → GRUB → Kernel → Init → 腳本),並針對 MBR 損壞、/etc/fstab 錯誤、GRUB 配置遺失、/etc/inittab 遺失、雙系統引導修復等典型故障,提供單用戶模式、GRUB 命令列、Linux 救援模式三大修復手段的完整操作步驟與實戰案例。

開機流程關鍵點

BIOS → MBR (446 bytes) → GRUB Menu → Kernel 載入 → Init (PID 1) → /etc/rc.d/rc.sysinit → 各 Runlevel 腳本

單用戶模式(Runlevel 1)應用

  • 啟動時按任意鍵進入 GRUB,編輯 kernel 行尾加 single 或 s 啟動。
  • 適用:重設 root 密碼、修復 /etc/fstab、還原配置檔。

GRUB 命令列手動引導

grub> find /boot/grub/grub.conf
grub> root (hd0,0)
grub> kernel /boot/vmlinuz-... ro root=LABEL=/
grub> initrd /boot/initrd-...img
grub> boot

適用:grub.conf 遺失/損壞、測試新編譯內核。

Linux 救援模式(光盤啟動 linux rescue)

  1. 光盤啟動,輸入 linux rescue,選擇語言/鍵盤/網路(可跳過)。
  2. 掛載系統根分區至 /mnt/sysimage(選讀寫模式)。
  3. chroot /mnt/sysimage 切換至目標系統環境。

案例:雙系統 GRUB 修復

chroot /mnt/sysimage
grub-install /dev/hda   # 或 /dev/sda
exit; exit; reboot

案例:/etc/inittab 遺失修復

# 有備份
cp /etc/inittab.bak /etc/inittab

# 無備份,重裝套件
rpm -qf /etc/inittab          # 查詢屬於 initscripts 套件
mount /dev/hdc /mnt/source    # 掛載安裝光盤
rpm -ivh --replacepkgs --root /mnt/sysimage /mnt/source/Fedora/RPMS/initscripts-*.rpm

MBR 備份與還原

# 備份
dd if=/dev/sda of=/tmp/mbr.bak bs=446 count=1

# 還原
dd if=/tmp/mbr.bak of=/dev/sda bs=446 count=1
Copyright © Windows教程網 All Rights Reserved