Rescue mode provides the ability to boot a small Fedora environment entirely from CD-ROM, or some other boot method, instead of the system's hard drive.
As the name implies, rescue mode is provided to rescue you from something. During normal operation, your Fedora system uses files located on your system's hard drive to do everything — run programs, store your files, and more.
However, there may be times when you are unable to get Fedora running completely enough to access files on your system's hard drive. Using rescue mode, you can access the files stored on your system's hard drive, even if you cannot actually run Fedora from that hard drive.
要进入救援模式,你必须能够用下面方法中的一种来引导系统[]:
By booting the system from an installation boot CD-ROM or DVD.
从其他安装引导介质,如 USB 闪存设备引导系统。
By booting the system from the Fedora CD-ROM #1 or DVD.
使用以上方法引导后,把 rescue
添加为内核参数。例如,对于 x86 系统,在安装引导提示下输入以下命令:
linux rescue
You are prompted to answer a few basic questions, including which language to use. It also prompts you to select where a valid rescue image is located. Select from Local CD-ROM, Hard Drive, NFS image, FTP, or HTTP. The location selected must contain a valid installation tree, and the installation tree must be for the same version of Fedora as the Fedora disk from which you booted. If you used a boot CD-ROM or other media to start rescue mode, the installation tree must be from the same tree from which the media was created. For more information about how to setup an installation tree on a hard drive, NFS server, FTP server, or HTTP server, refer to the earlier section of this guide.
如果你选择的救援映像不需要网络连接,你会被征询是否要建立网络连接。如果你想把文件备份到另一台计算机上或从共享网络位置上安装一些 PRM 软件包时,网络连接会很有用。
下面的信息将显示:
The rescue environment will now attempt to find your Linux installation and mount it under the directory /mnt/sysimage. You can then make any changes required to your system. If you want to proceed with this step choose 'Continue'. You can also choose to mount your file systems read-only instead of read-write by choosing 'Read-only'. If for some reason this process fails you can choose 'Skip' and this step will be skipped and you will go directly to a command shell.
如果你选择 Continue,它会试图把你的文件系统挂载到 /mnt/sysimage
目录下。如果它挂载分区失败,它会通知你。如果你选择 Read-Only,它会试图在 /mnt/sysimage
目录下挂载你的文件系统,但是挂载模式为只读。如果你选择 Skip,你的文件系统将不会被挂载。如果你认为你的文件系统已损坏,选择 Skip。
一旦你的系统进入了救援模式,在 VC(虚拟控制台)1和 VC2(使用 Ctrl-Alt-F1 组合键来进入 VC1,Ctrl-Alt-F2 来进入 VC2)上会出现提示:
sh-3.00b#
如果你选择了 Continue 来自动挂载你的分区,并且它们被成功地挂载了,那么你就会进入单用户模式。
即便你的文件系统被挂载,救援模式中的默认根分区只不过是一个临时的根分区,而不是正常用户模式(运行级别3或5)中的文件系统根分区。如果你选择要挂载文件系统,并且它被成功地挂载了,你可以通过执行以下命令来把救援模式的根分区改变为你的文件系统的根分区:
chroot /mnt/sysimage
如果你需要运行 rpm
之类的命令,改变根分区就会很有用,因为这类命令要求你的根分区被挂载为 /
。要退出 chroot
环境,键入 exit
,你就会返回到提示。
如果你选择 Skip,你仍可以试图在救援模式中手工挂载分区或 LVM2 逻辑卷,方法是:创建一个目录,如, /foo
,然后键入以下命令:
mount -t ext4 /dev/mapper/VolGroup00-LogVol02 /foo
In the above command, /foo
is a directory that you have created and /dev/mapper/VolGroup00-LogVol02
is the LVM2 logical volume you want to mount. If the partition is of type ext2
or ext3
replace ext4
with ext2
or ext3
respectively.
如果你不知道所有物理分区的名字,你可以使用以下命令来列举它们:
fdisk -l
如果你不知道所有 LVM2 物理卷、逻辑组或是逻辑卷的名称,使用以下命令来列举它们:
pvdisplay
vgdisplay
lvdisplay
在这个提示下,你可以运行许多有用的命令,例如:
ssh
、scp
和 ping
,查看网络是否被启动
dump
和 restore
,用于带有磁带驱动器的用户
parted
和 fdisk
,用来管理分区
rpm
,用于安装或升级软件
joe
用于编辑配置文件
Note
如果你试图启动其它常用的编辑器,如 emacs
、pico
或 vi
,joe
编辑器仍会被启动。
17.2.1. 重新安装引导装载程序
在很多情况下,GRUB 引导装载程序可能被错误地删除、损坏或者被其他操作系统代替。
下面的步骤详细说明了怎样把 GRUB 重新安装在主引导分区(MBR)里:
从安装引导介质中引导系统。
在安装引导提示下键入 linux rescue
来进入救援环境。
键入 chroot /mnt/sysimage
来挂载根分区。
键入 /sbin/grub-install /dev/hda
来重新安装 GRUB 引导装载程序,这里的 /dev/hda
是 boot 分区。
检查 /boot/grub/grub.conf
文件,因为要控制其他的操作系统,GRUB 需要额外的条目。
重新启动系统。