/boot/grub/grub.conf 损坏或丢失会导致启动停留在 grub> 提示符,无法进入系统。使用安装光盘 Linux Rescue 模式 挂载根分区,手工重写 grub.conf 并重装 GRUB 至 MBR 即可恢复启动。
linux rescue 回车。/mnt/sysimage,选择 Continue。chroot /mnt/sysimage
# 编写最小 grub.conf
cat > /boot/grub/grub.conf <<'EOF'
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-71.el6.i686)
root (hd0,0)
kernel /vmlinuz-2.6.32-71.el6.i686 ro root=/dev/sda3 rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto quiet
initrd /initramfs-2.6.32-71.el6.i686.img
EOF
# 注意:
# root (hd0,0) 对应 /boot 分区 (/dev/sda1)
# kernel 行 root=/dev/sda3 对应根分区
# 请根据 fdisk -l 实际分区调整
grub --batch <<'EOF'
root (hd0,0)
setup (hd0)
quit
EOF
exit
exit
reboot
grub.conf:cp /boot/grub/grub.conf /boot/grub/grub.conf.bak。grub-install 与更新配置。grub2-install --target=x86_64-efi 与 grub2-mkconfig。
救援模式 chroot 重写 grub.conf 并 grub setup (hd0) 重装引导扇区,可快速修复因配置丢失导致的启动失败。养成备份习惯可避免手工重写配置的繁琐。