Chapter 3. Rescue Mode

When things go wrong, there are ways to fix problems. However, these methods require that you understand the system well. This chapter will describe the ways that you can boot into rescue modes, where you can use your own knowledge to repair the system.

What is Rescue Mode?

Rescue mode is the ability to boot a small Linux environment entirely from a diskette or CD, or using some other method.

As the name implies, rescue mode is provided to rescue you from something. During normal operation, your Red Hat Linux 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 Linux running completely enough to access its 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 Linux from that hard drive.

Normally, you will need to get into rescue mode for one of two reasons:

Next, we will take a closer look at each of these scenarios.

Unable to Boot Linux

This problem is often caused by the installation of another operating system after you have installed Red Hat Linux. Some other operating systems assume that you have no other operating systems on your computer, and overwrite the Master Boot Record (MBR) that originally contained the LILO bootloader. If LILO is overwritten in this manner, you will not be able to boot Red Hat Linux unless you can get into rescue mode.

Hardware/Software Problems

This category includes a wide variety of different situations. Two examples include failing hard drives and forgetting to run LILO after building a new kernel. In both of these situations, you may be unable to boot Red Hat Linux. If you can get into rescue mode, you might be able to resolve the problem or at least get copies of your most important files.

To boot your system in rescue mode, enter the following command at the installation boot prompt:

boot: linux rescue

You can get to the installation boot prompt in one of these ways:

  • By booting your system from an installation boot diskette [1] or the Red Hat Linux CD-ROM #1.

  • By booting from a network or PCMCIA boot diskette. You can only do this if your network connection is working. You will need to identify the network host and transfer type. For an explanation of how to specify this information, see Installing over the Network in the Official Red Hat Linux x86 Installation Guide.

Once you have your system in rescue mode, a prompt appears on VC (virtual console) 2 (use the [Ctrl]-[Alt]-[F2] key combination to access VC 2):

bash#

From this prompt, you can run many useful commands including:

anaconda          gzip        mkfs.ext2   ps
badblocks         head        mknod       python
bash              hwclock     mkraid      python1.5
cat               ifconfig    mkswap      raidstart
chattr            init        mlabel      raidstop
chmod             insmod      mmd         rcp
chroot            less        mmount      rlogin
clock             ln          mmove       rm
collage           loader      modprobe    rmmod
cp                ls          mount       route
cpio              lsattr      mpartition  rpm
dd                lsmod       mrd         rsh
ddcprobe          mattrib     mread       sed
depmode           mbadblocks  mren        sh
df                mcd         mshowfat    sync 
e2fsck            mcopy       mt          tac
fdisk             mdel        mtools      tail
fsck              mdeltree    mtype       tar
fsck.ext2         mdir        mv          touch
fsck.ext3         mdu         mzip        traceroute
ftp               mformat     open        umount
gnome-pty-helper  minfo       pico        uncpio
grep              mkdir       ping        uniq
gunzip            mke2fs      probe       zcat

However, if your root filesystem is undamaged, you can mount it and then run any standard Linux utility. For example, if your root filesystem is in /dev/hda5, you can mount this partition with the following command:

mount -t ext2 /dev/hda5 /foo

In the above command, /foo is a directory that you have created.

At this point, you can run chroot, fsck, man, and other utilities. You are running Linux in single-user mode.

If you do not know the names of your Linux partitions, you can guess what they are. Mounting non-existent partitions will do no harm.

Booting Single-User Mode Directly

You may be able to boot single-user mode directly. If your system boots, but does not allow you to log in when it has completed booting, try rebooting and specifying one of these options at the LILO boot prompt (if you are using the graphical LILO, you must press [Ctrl]-[x] to exit the graphical screen and go to the boot: prompt):

boot: linux single
boot: linux emergency

In single-user mode, you computer boots to runlevel 1. Your local filesystems will be mounted, but your network will not be activated. You will have a usable system maintenance shell.

In emergency mode, you are booted into the most minimal environment possible. The root filesystem will be mounted read-only and almost nothing will be set up. The main advantage of emergency mode over linux single is that your init files are not loaded. If init is corrupted or not working, you can still mount filesystems to recover data that could be lost during a re-installation.

Have you ever rebuilt a kernel and, eager to try out your new handiwork, rebooted before running /sbin/lilo? If you did not have an entry for an older kernel in lilo.conf, you had a problem. If you would like to know a solution to this problem, read this section.

In many cases, you can boot your Red Hat Linux system from the Red Hat Linux boot disk [1] with your root filesystem mounted and ready to go. Here is how to do it:

Enter the following command at the boot disk's boot: prompt:

linux single root=/dev/hdXX initrd=

Replace the XX in /dev/hdXX with the appropriate letter and number for your root partition.

What does this command do? First, it starts the boot process in single-user mode, with the root partition set to your root partition. The empty initrd specification bypasses the installation-related image on the boot disk, which will cause you to enter single-user mode immediately.

Is there a negative side to using this technique? Unfortunately, yes. Because the kernel on the Red Hat Linux boot disk only has support for IDE built-in, if your system is SCSI-based, you will not be able to do this. In that case, you will have to access rescue mode using the linux rescue command mentioned above.

Notes

[1]

To create an installation boot diskette use the images/boot.img file on the Red Hat Linux CD-ROM #1 with the command dd if=boot.img of=/dev/fd0 and a blank diskette.