在 GRUB 2 救援模式下修复 Linux 引导失败
在此页
- 它看起来怎么样?
- 可用的基本命令。
- 救援壳。
- 启动系统后。
由于 GRUB 2 修复引导问题的能力比原来的 GRUB 引导加载程序有了很大的改进。本文为您提供有关修复 GRUB 2 引导问题的可用选项的信息以及有关如何使用 GRUB 2 终端的具体说明。这些说明是为 GRUB 2 编写的。
它看起来怎么样?
当 GRUB 引导失败时,基本上有三个错误消息或屏幕。
grub>:这是当 GRUB 找到除配置文件以外的所有内容时您看到的屏幕模式。该文件可能是 grub.conf。
grub rescue>:这是 GRUB 2 无法找到 GRUB 文件夹或其内容丢失/损坏时的模式。 GRUB 2 文件夹包含菜单、模块和存储的环境数据。
GRUB:只是 \GRUB\ 没有别的表明 GRUB 2 未能找到启动系统所需的最基本信息。
这些是引导过程中可能出现的基本错误。尽管在屏幕上可以看到更多错误,如冻结启动画面、Busybox 或 Initramfs:GRUB 2 开始....
但是每个 GRUB 2 故障模式都可以从 GRUB 2 终端或发行版的 Live 引导 CD 或 DVD,也有可用的第 3 方救援工具。
可用的基本命令。
这些是当您通过按 \c\ 进入 GRUB 2 终端模式时可以使用的命令。
boot (Initiate the boot, also F10 or CTRL-x)
cat (view the contents of config or txt files; cat (hd0,1)/boot/grub/grub.cfg)
configfile (Load a GRUB 2 configuration file such as grub.cfg; configfile (hd0,5)/boot/grub/grub.cfg.)
initrd (Loads the initrd.img, necessary for booting; initrd (hd0,5)/initrd.img.)
insmod (Loads a module; insmod (hd0,5)/boot/grub/normal.mod, or insmod normal.)
linux (Loads the kernel; insmod /vmlinuz root=(hd0,5) ro.)
loop (Mount a file as a device; loopback loop (hd0,2)/iso/my.iso.)
ls (lists the contents of a partition/folder; ls, ls /boot/grub, ls (hd0,5)/, ls (hd0,5)/boot.)
lsmod (List loaded modules.)
normal (Activate the normal module, if loaded.)
search (Search for a device. Type help search for the available options.)
set (Review current settings, or set XXX to set a variable such as colors, prefix, root.)
vbeinfo (Display GRUB 2 available resolutions.)
救援壳。
如果您得到一个救援 shell,这通常意味着 GRUB 由于某种原因未能加载“正常”模块。可能暂时解决这个问题:例如,如果失败的原因是“prefix”错误(可能它指的是错误的设备,或者可能是“/boot/grub”的路径)相对于设备没有正确制作),那么你可以更正它并手动进入正常模式:检查当前前缀(和其他预设变量):
set

ls

set prefix=(hd0,1)/grub
(这必须根据您自己的驱动器名称来完成)
set root=(hd0,1)
(这必须根据您自己的驱动器名称执行。)
insmod normal
normal
上面的命令会让你退出救援模式,进入正常的终端模式。在终端模式下,您有更多的命令和更多的功能。
在上述命令之后,您可以继续并开始其余的设置。
insmod linux
* linux /vmlinuz root=/dev/sdXY ro
(如果这不起作用试试这个)
linux /boot/vmlinuz-3.2.0-14-generic root=/dev/sda1 ro
(选修的)
initrd /initrd.img
(选择 initrd 映像。)
boot
引导系统后。
更新 GRUB 配置文件。
sudo update-grub
在设备上重新安装 Grub:
sudo grub-install /dev/sdX
这应该是救援部分,你的系统应该是好的并且正在运行。如果没有,您可以使用启动修复来省去所有麻烦。这是用于修复完整启动菜单的工具。它可以直接下载并用作 Live Boot CD 或 DVD。这是下载链接。