你好,游客 登录 注册 搜索
背景:
阅读新闻

如何拯救一台GRUB 2启动失败的Linux电脑

[日期:2014-07-24] 来源:Linux中国  作者:Linux [字体:大 中 小]

从 grub> 中启动

下面讲述如何设置启动文件并从grub >提示下启动系统。我们已经知道如何从Linux根文件系统(hd0,1)下运行ls命令,你可以一直寻找直到找到你的/boot/grub所在位置。然后运行以下命令,记得使用您自己的根分区,内核和initrd映像等参数:

  1. grub>set root=(hd0,1)
  2. grub> linux /boot/vmlinuz-3.13.0-29-generic root=/dev/sda1
  3. grub> initrd /boot/initrd.img-3.13.0-29-generic
  4. grub> boot

第一行设置分区的根文件系统。第二行告诉GRUB您想要使用的内核位置。开始输入/boot/vmli,然后使用tab补完填写。输入root= /dev/sdX设置根文件系统位置。是的,这似乎是多余的,但如果你忘记了输入,你会得到一个kernel panic。你知道怎么找到正确的分区吗?hd0,1 即 /dev/sda1,hd1,1 即 /dev/sdb1,hd3,2 即 /dev/ sdd2。我想你可以自己推算剩下的了。

第三行设置initrd文件,必须是和内核相同的版本号。

最后一行启动系统。

在一些Linux系统上,内核和initrd是被符号链接到当前的根文件系统的根目录,就像:

  1. $ ls -l /
  2. vmlinuz -> boot/vmlinuz-3.13.0-29-generic
  3. initrd.img -> boot/initrd.img-3.13.0-29-generic

所以,你也可以这样输入命令:

  1. grub>set root=(hd0,1)
  2. grub> linux /vmlinuz root=/dev/sda1
  3. grub> initrd /initrd.img
  4. grub> boot

从grub rescue> 中启动

如果你处在grub rescue> 命令界面下,命令有所不同,你必须要先加载两个模块normal.mod 和 linux.mod。

  1. grub rescue>set prefix=(hd0,1)/boot/grub
  2. grub rescue>set root=(hd0,1)
  3. grub rescue> insmod normal
  4. grub rescue> normal
  5. grub rescue> insmod linux
  6. grub rescue> linux /boot/vmlinuz-3.13.0-29-generic root=/dev/sda1
  7. grub rescue> initrd /boot/initrd.img-3.13.0-29-generic
  8. grub rescue> boot

在你加载了这两个模块之后tab补完的功能就可以用了。

永久性的修复

当你成功地启动你的系统,运行这些命令来永久修复GRUB:

  1. # update-grub
  2. Generating grub configuration file ...
  3. Found background:/usr/share/images/grub/Apollo_17_The_Last_Moon_Shot_Edit1.tga
  4. Found background image:/usr/share/images/grub/Apollo_17_The_Last_Moon_Shot_Edit1.tga
  5. Found linux image:/boot/vmlinuz-3.13.0-29-generic
  6. Found initrd image:/boot/initrd.img-3.13.0-29-generic
  7. Found linux image:/boot/vmlinuz-3.13.0-27-generic
  8. Found initrd image:/boot/initrd.img-3.13.0-27-generic
  9. Found linux image:/boot/vmlinuz-3.13.0-24-generic
  10. Found initrd image:/boot/initrd.img-3.13.0-24-generic
  11. Found memtest86+ image:/boot/memtest86+.elf
  12. Found memtest86+ image:/boot/memtest86+.bin
  13. done
  14. # grub-install /dev/sda
  15. Installingfor i386-pc platform.
  16. Installation finished.No error reported.

当你运行 grub-install 时,记得GRUB是安装到整个硬盘驱动器的主引导扇区而不是到一个具体分区,所以不要加上像/dev/sda1一样的分区号。

如果还是不能使用

如果你的系统是如此的倒霉,而且这个方式没有能起作用,那就尝试超级GRUB2现场救援磁盘吧。官方GNU GRUB手册也应该有所帮助。


via: http://www.linux.com/learn/tutorials/776643-how-to-rescue-a-non-booting-grub-2-on-linux

译者:MikeCoder 校对:wxy

本文由 LCTT 原创翻译,Linux中国 荣誉推出

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-07/104610.htm

linux
相关资讯       GRUB 2  GRUB 2启动 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款