遺忘 GRUB 開機密碼會阻礙進入單用戶模式重置 root 密碼,形成「雙重鎖死」。本文提供兩種通用破解路徑,適用於 GRUB Legacy (0.9x) 與 GRUB 2,涵蓋 BIOS 與 UEFI 環境。
/mnt/sysimage。若未自動掛載:mkdir /mnt/sysimagemount /dev/sda2 /mnt/sysimage # 根分區mount /dev/sda1 /mnt/sysimage/boot # /boot 獨立分區時/mnt/sysimage/boot/grub/grub.conf 或 menu.lst):password [--md5] <hash> 行。/mnt/sysimage/boot/grub2/grub.cfg、/mnt/sysimage/etc/grub.d/40_custom):/etc/grub.d/40_custom 或 /boot/grub2/user.cfg。/mnt/sysimage/etc/grub.d/40_custom,刪除 set superusers= 與 password_pbkdf2 區塊。grub2-setpassword 設定,刪除 /mnt/sysimage/boot/grub2/user.cfg。chroot /mnt/sysimagegrub2-mkconfig -o /boot/grub2/grub.cfgexite 進入編輯模式。e,行尾加 single 或 init=/bin/bash。b 啟動,進入單用戶/root shell。mount -o remount,rw /boot。/boot/grub/grub.conf 移除 password 行。reboot。e 編輯啟動項。linux / linux16 / linuxefi 行,行尾加 rd.break(進入 initramfs shell)或 init=/bin/bash。Ctrl+x 啟動。mount -o remount,rw /sysrootchroot /sysroot/etc/grub.d/40_custom 移除密碼設定。grub2-mkconfig -o /boot/grub2/grub.cfgtouch /.autorelabel # SELinux 重新標記exit; exit 離開 chroot 與 initramfs shell,系統繼續啟動。# GRUB 2 設定 PBKDF2 加密密碼
grub2-setpassword
# 輸入兩次新密碼,自動更新 /boot/grub2/user.cfg
# 重新生成配置
grub2-mkconfig -o /boot/grub2/grub.cfg
同步建議:BIOS/UEFI 設定開機密碼、啟用 Secure Boot、實體機箱加鎖,構建多層物理與邏輯防線,防止再次被繞過。