8.7. 修复损坏的系统

有时候,会遇到一些麻烦,您小心翼翼安装的系统无法启动。可能是由于调整启动加载程序时损坏了配置文件,或者新准备的内核无法启动,或者宇宙射线撞击了您的硬盘造成 /sbin/init 中的一位反转。无论什么原因,修复时您都需要一个可以工作的系统,rescue 模式正好用于此目的。

To access rescue mode, select rescue from the boot menu, type rescue at the boot: prompt, or boot with the rescue/enable=true boot parameter. You'll be shown the first few screens of the installer, with a note in the corner of the display to indicate that this is rescue mode, not a full installation. Don't worry, your system is not about to be overwritten! Rescue mode simply takes advantage of the hardware detection facilities available in the installer to ensure that your disks, network devices, and so on are available to you while repairing your system.

取代分区工具的,是显示您系统上的分区列表,并请您选择。通常,您应该选择修复包含 root 文件系统的分区。您也可以选择 RAID 和 LVM 设备上的分区,与直接在磁盘上创建一样。

如可能,安装程序将在您选择的文件系统上给出一个 shell 提示符,通过它可以执行一些必要的修复操作。例如,您需要在第一个硬盘的主引导区重装 GRUB 引导程序,可以通过输入这个命令 grub-install '(hd0)' 完成。

假如安装程序在您选择的 root 文件系统上不能运行一个可用的 shell,这可能是因为文件系统已经损坏,那么将发出警告,并通过安装程序的环境提供一个 shell。您在这个环境下可能没有丰富的工具可用,但足以应付系统修复工作。您选择的 root 文件系统将挂载到 /target 目录。

无论哪种情况,退出 shell 之后,系统将重启。

最后,要注意修复一个损坏的系统可能非常困难,在这份手册里面不会列举所有的情况和修复方法。如果您遇到困难,请咨询专家。