Red Hat Linux 6.1: The Official Red Hat Linux Reference Guide | ||
---|---|---|
Prev | Chapter 2. System Administration | Next |
Rescue mode is a term used to describe a method of booting a small Linux environment completely from diskettes.
What follows in this section may help you recover from a problem at some point. A copy of these instructions is also available as rescue.txt on your Red Hat Linux 6.1 CD-ROM.
As the name implies, rescue mode is there to rescue you from something. In 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. By using rescue mode, it's possible to access the files stored on your system's hard drive, even if you can't actually run Linux from that hard drive.
Normally, you'll need to get into rescue mode for one of two reasons:
You are unable to boot Linux, and you'd like to fix it.
You are having hardware or software problems, and you want to get a few important files off your system's hard drive.
Let's take a closer look at each these scenarios.
Many times this is caused by the installation of another operating system after you've 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 (or MBR) that originally contained the LILO bootloader. If LILO is overwritten in this manner, you're out of luck -- unless you can get into rescue mode.
There can be as many different situations under this category as there are systems running Linux. Things like failing hard drives and forgetting to run LILO after building a new kernel are just two instances that can keep you from booting 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.
What do you need to get into rescue mode?
To get into rescue mode, you'll need a rescue disk set. These are two diskettes that contain the files necessary to boot into rescue mode.
If you elected to make a boot disk while you were installing Red Hat Linux, you're halfway there! The first diskette in a rescue disk set is this boot disk.
Now on to the second diskette…
The second diskette is called the rescue disk. It is produced by writing an image file onto a diskette. The image file is called rescue.img, and is located in the images directory on the first Red Hat Linux CD-ROM.
To gain access to this file, you'll first need to mount your Red Hat Linux CD-ROM.
Start by inserting the CD-ROM in your system's CD-ROM drive. You'll need to do this while logged in as root.
Type the following command:
mkdir /mnt/cdrom |
Now, type:
mount /dev/cdrom /mnt/cdrom |
You may get an error message from the first command saying that the file exists. That's fine; we just want to make sure that there is a /mnt/cdrom directory on your system. The second command should issue an informational message that /dev/cdrom is being mounted read-only.
Please Note: Some systems may not recognize /dev/cdrom. If this is your case, you'll have to replace /dev/cdrom in the command with the appropriate device name for your CD-ROM.
Next, issue the following command (again, while logged in as root):
cd /mnt/cdrom/images |
then type:
ls |
to list the contents of the images directory.
You should see a file named rescue.img. This is the rescue disk image file. Next, put a diskette in your first diskette drive, and enter the following command:
dd if=rescue.img of=/dev/fd0 bs=1440k |
Your system's diskette drive should start writing to the diskette. After a minute or so, the dd command will complete, and you'll get your shell prompt back.
Wait for your diskette drive's access light to go out, and that's it!
You now have a rescue disk set. Label this diskette something like "Red Hat Linux 6.1 rescue disk" and store it someplace safe.
Let's hope you never have to use it.
If you should ever need to use rescue mode, here's how.
Boot your system with the boot disk in the first diskette drive. At the LILO Boot: prompt, enter the word rescue. You will see the usual kernel messages as the Linux kernel starts up.
Eventually, it will ask you to insert the next diskette, and press Enter. Remove the boot disk, insert the rescue disk, and press Enter.
The rescue disk will be read into memory. After a minute or so, you should see the shell prompt. That's it -- you're in rescue mode!
Now what?
When it comes to rescue mode, that's a bit like asking, "how long is a piece of string?" What you require depends a great deal on what your system's problem is, your level of Linux expertise, and several variables we haven't even thought of yet. So we can't give you explicit instructions.
But we can tell you what programs you have access to while in rescue mode.
Here's the list:
badblocks bash bzip2 cat chmod chroot cp cpio dd e2fsck fdisk grep gunzip gzip head ifconfig init ln ls lsmod mkdir mke2fs mknod mount mt mv open pico ping ps restore rm route rpm sed sh swapoff swapon sync tac tail tar traceroute umount vi vim |
You're likely to be unfamiliar with most, if not all of these commands. However, the commands do have man pages. Once you begin to feel more comfortable with commands, you should consider familiarizing yourself them through the man pages. (You may not have that luxury if you have to use these commands …)
If your system boots, but does not allow you to log in when it has completed booting, you can use the single or emergency boot option. At the LILO boot: prompt, type linux single in order to boot in single-user mode. In single-user mode, your local filesystems will be mounted, but your network will not be activated. In emergency mode, almost nothing will be set up. Only the root filesystem will be mounted, and it will be mounted read-only.
The boot disk created during installation of Red Hat Linux 6.1 may be used as part of a rescue disk set. For more information, please read the file rescue.txt in the /doc directory on your Red Hat Linux 6.1 CD-ROM or refer to the Official Red Hat Linux Getting Started Guide.
Have you ever rebuilt a kernel and, eager to try out your new handiwork, rebooted before running LILO? And you didn't have an entry for an older kernel in lilo.conf? Read on…
Here's a handy trick. In many cases, it's possible to boot your Red Hat Linux/Intel system from the Red Hat Linux boot disk with your root filesystem mounted and ready to go. Here's how:
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 do? First, it starts the boot 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 downside to this trick? Unfortunately, yes. Because the kernel on the Red Hat Linux boot disk only has support for IDE built-in, those of you with SCSI-based systems won't be able to use this trick. In that case, you'll have to use the boot/rescue disk combination mentioned above.