Skip to content

Instantly share code, notes, and snippets.

@junfenglx
Created August 16, 2015 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junfenglx/cf85adaf0b77c5df8be6 to your computer and use it in GitHub Desktop.
Save junfenglx/cf85adaf0b77c5df8be6 to your computer and use it in GitHub Desktop.
grub rescue. repost from douban

###grub rescue模式下修复

由于在rescue模式下,只有少量的基本命令可用,必须通过一定的操作才能加载正常模块,然后进入正常模式。

rescue模式下可使用的命令有:set,ls,insmod,root,prefix(设置启动路径)

先假设grub2的核心文件在(hd0,8)分区,再来看看怎样从 rescue模式进入从(hd0,8)启动的正常模式(normal)。

在 rescue模式下search命令不能用,对不清楚grub2文件处于哪个分区的,可以用ls命令查看,比如

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 normal

rescue>normal -------->若出现启动菜单,按c进入命令行模式

rescue>linux /boot/vmlinuz-xxx-xxx root=/dev/sdax

rescue>initrd /boot/initrd.img-xxx-xxx

rescue>boot

内核版本号 -xxx-xxx可以按Tab键查看后再手动补全。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment