由于在rescue模式下,只有少量的基本命令可用,必须通过一定的操作才能加载正常模块,然后进入正常模式。
rescue模式下可使用的命令有:set,ls,insmod,root,prefix(设置启动路径)
先假设grub2的核心文件在(hd0,8)分区,再来看看怎样从 rescue模式进入从(hd0,8)启动的正常模式(normal)。
在 rescue模式下search命令不能用,对不清楚grub2文件处于哪个分区的,可以用ls命令查看,
比如(hd0) (hd0,msdos9)。。。。。
ls (hd0,8)/ 查看(hd0,8)分区根目录,看看有没有boot文件夹
ls (hd0,8)/boot/ 查看(hd0,8)分区的/boot目录下文件
ls (hd0,8)/boot/grub/ 查看(hd0,8)分区/boot/grub目录下文件
通过文件查看,可以确定 grub2核心文件处于哪个分区,接下来就可以进行从rescue到normal的转变动作:
先 ls 看看分区,根据分区列表,猜下 / 分区的编号再 ls (hd0,x)/ 看分区目录下文件确定找到 / 分区,不对的话继续找。找到 / 分区的 (hd0,x) 继续
grub rescue>root=(hd0,x)
grub rescue>prefix=/boot/grub
------------------下面是主要的处理方法------------ grub rescue>set root=(hd0,x) grub rescue>set prefix=(hd0,x)/boot/grub grub rescue>insmod /boot/grub/normal.mod rescue>normal --------> 启动后 进入系统后再执行 代码: sudo grub-install /dev/sda(x) #重建grub sda(x)代表启动分区 -------------修复完毕--------------------
若出现启动菜单,按c进入命令行模式
rescue>linux /boot/vmlinuz-xxx-xxx root=/dev/sdax
rescue>initrd /boot/initrd.img-xxx-xxx
rescue>boot
内核版本号 -xxx-xxx可以按Tab键查看后再手动补全。
转载于:https://blog.51cto.com/itjiejue/698734