Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

Chapter 33. System Recovery

Red Hat Enterprise Linux 6 offers three system recovery modes, rescue mode, single-user mode, and emergency mode that can be used to repair malfunctioning systems. This chapter describes how to boot into each system recovery mode and gives guidance to resolve certain problems that can only be solved with help of system recovery modes.
These are the usual reasons why you may need to boot to one of the system recovery modes:
  • You are unable to boot normally into Red Hat Enterprise Linux (runlevel 3 or 5).
  • You need to resolve hardware or software problems that cannot be resolved while the system is running normally, or you want to access some important files off of your hard drive.
  • You forgot the root password.
Some of the problems behind are further discussed in Section 33.4, “Resolving Problems in System Recovery Modes”.

33.1. Rescue Mode

Rescue mode provides the ability to boot a small Red Hat Enterprise Linux environment entirely from external media, such as CD-ROM or USB drive, instead of the system's hard drive. It contains command-line utilities for repairing a wide variety of issues. In this mode, you can mount file systems as read-only or even to not mount them at all, blacklist or add drivers provided on a driver disc, install or upgrade system packages, or manage partitions.
To boot into rescue mode follow this procedure:

Procedure 33.1. Booting into Rescue Mode

  1. Boot the system from either minimal boot media, or a full installation DVD or USB drive, and wait for the boot menu to appear. For details about booting the system from the chosen media, see the respective chapters in the Installation Guide.
  2. From the boot menu, append the rescue keyword as a kernel parameter to the boot command line.
  3. If your system requires a third-party driver provided on a driver disc to boot, append the additional option dd to the boot command line to load that driver:
    rescue dd
    For more information about using a disc driver at boot time, see the respective chapters in the Installation Guide.
  4. If a driver that is a part of the Red Hat Enterprise Linux 6 distribution prevents the system from booting, blacklist that driver by appending the rdblacklist option to the boot command line:
    rescue rdblacklist=driver_name
  5. Answer a few basic questions and select the location of a valid rescue image as you are prompted to. Select the relevant type from Local CD-ROM, Hard Drive, NFS image, FTP, or HTTP. The selected location must contain a valid installation tree, and the installation tree must be for the same version of Red Hat Enterprise Linux as is the disk from which you booted. For more information about how to setup an installation tree on a hard drive, NFS server, FTP server, or HTTP server, see the respective chapters in the Installation Guide.
    If you select a rescue image that does not require a network connection, you are asked whether or not you want to establish a network connection. A network connection is useful if you need to backup files to a different computer or install some RPM packages from a shared network location.
  6. The following message is displayed:
    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.
    If you select Continue, the system attempts to mount your root partition under the /mnt/sysimage/ directory. The root partition typically contains several file systems, such as /home/, /boot/, and /var/, which are automatically mounted to the correct locations. If mounting the partition fails, you will be notified. If you select Read-Only, the system attempts to mount your file systems under the directory /mnt/sysimage/, but in read-only mode. If you select Skip, your file systems will not be mounted. Choose Skip if you think your file system is corrupted.
  7. Once you have your system in rescue mode, the following prompt appears on the virtual console (VC) 1 and VC 2. Use the Ctrl-Alt-F1 key combination to access VC 1 and Ctrl-Alt-F2 to access VC 2:
If you selected Continue to mount your partitions automatically and they were mounted successfully, you are in single-user mode.
Even if your file system is mounted, the default root partition while in rescue mode is a temporary root partition, not the root partition of the file system used during normal user mode (runlevel 3 or 5). If you selected to mount your file system and it mounted successfully, you can change the root partition of the rescue mode environment to the root partition of your file system by executing the following command:
sh-3.00b# chroot /mnt/sysimage
This is useful if you need to run commands, such as rpm, that require your root partition to be mounted as /. To exit the chroot environment, type exit to return to the prompt.
If you selected Skip, you can still try to mount a partition or a LVM2 logical volume manually inside rescue mode by creating a directory and typing the following command:
sh-3.00b# mkdir /directory
sh-3.00b# mount -t ext4 /dev/mapper/VolGroup00-LogVol02 /directory
where /directory 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 ext2 or ext3 type, replace ext4 with ext2 or ext3 respectively.
If you do not know the names of all physical partitions, use the following command to list them:
sh-3.00b# fdisk -l
If you do not know the names of all LVM2 physical volumes, volume groups, or logical volumes, use the pvdisplay, vgdisplay or lvdisplay commands, respectively.
From the prompt, you can run many useful commands, such as:
  • ssh, scp, and ping if the network is started
  • dump and restore for users with tape drives
  • parted and fdisk for managing partitions
  • rpm for installing or upgrading software
  • vi for editing text files