This document describes how rescue mode works in Red Hat Linux 5.1. NOTE: Rescue mode is supported only for Red Hat Linux/Intel! WHAT IS RESCUE MODE? Rescue mode is a term used to describe a method of booting a small Linux environment completely from diskettes. WHY IS THERE A RESCUE MODE? 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, etc. However, there may be times when you are, for one reason or another, 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. WHAT CAN I DO IN RESCUE MODE? Normally, you'll need to get into rescue mode for one of two reasons: o You are unable to boot Linux, and you'd like to fix it. o You are having hardware or software problems, and you want to get a few important files off your system's hard drive. Let's a take a closer look at each these scenarios. Unable to boot Linux -- 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. Hardware/Software problems -- 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 things than 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 I NEED TO GET INTO RESCUE MODE? You need a rescue disk set. These are two diskettes that contain the files necessary to boot into rescue mode. HOW DO I PRODUCE A RESCUE DISK SET? 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. If you didn't make it, no problem; it's easy to do. There's a program called "mkbootdisk" that does exactly that. You probably installed it when you installed Red Hat Linux. You can use the Red Hat Package Manager to find out if you did; simply type: rpm -q mkbootdisk If it returns something like "mkbootdisk-1.0-1", you're in business! (If you got a message saying the package is not installed, and you're sure you entered the command properly, skip to the end of this document, and we'll help you get it installed.) To make a boot disk with mkbootdisk, you need to know what version of the Linux kernel your system is running. Enter the following command to find out: uname -r This command should return a set of numbers -- something like "2.0.34". Write down that number, because you're going to need to enter it just as it's displayed. Now it's time to run mkbootdisk. The basic format of the mkbootdisk command is: mkbootdisk Where is the version of the running Linux kernel. So if, for example, your system is running version 2.0.34, you should enter this command (make sure you're logged in as root): mkbootdisk 2.0.34 You'll be asked to insert a diskette in your first diskette drive (the one your system tries to boot from when you turn on your computer). Do so, and press . Your system's diskette drive should clunk away for a while. After a minute or so, the command should be done. Congratulations, you now have a boot diskette! Remove it from your diskette drive, label it appropriately (keeping in mind that this diskette is customized for this *one* system), and store it someplace safe. Now on to the second diskette... The second diskette is called the rescue diskette. It is the same for every system running Red Hat Linux 5.1. 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. Issue the following commands: mkdir /mnt/cdrom 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 (Note: some systems may not recognize /dev/cdrom. If this is the case, you'll have to replace /dev/cdrom in the command with the appropriate device name for your CD-ROM). Next, issue the following commands (again, while logged in as root): cd /mnt/cdrom/images ls You should see a file named rescue.img. This is the rescue diskette 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 a shell prompt back. That's it! You now have a rescue disk set. Label this diskette something like "Red Hat Linux 5.1 rescue diskette", and store it someplace safe. Let's hope you never have to use it. But to make sure your rescue disk set is working properly, let's give them a try right now. Shut your system down as you would normally ("shutdown -h now" works pretty well). IF YOU HAVE TO USE RESCUE MODE If you should ever need to use rescue mode, here's how. Boot your system with the boot diskette in the first diskette drive. At the "LILO Boot:" prompt, enter the word "rescue" (without the quotes). 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 . Remove the boot diskette, insert the rescue diskette, and press . The rescue diskette will be read into memory. After a minute or so, you should see a "bash#" prompt. That's it -- you're in rescue mode! WHAT DO I DO NOW? When it comes to rescue mode, that's a bit like asking, "how long is a piece of string?" -- what you need to do depends a great deal on what your system's problem is, your level of Linux expertise, and several other 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 If any of these commands are unfamiliar to you, now would be a good time to look at some man pages; you may not have that luxury when you have to use these commands for real... The Red Hat Linux Development Team INSTALLING THE MKBOOTDISK PACKAGE 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. Issue the following commands: mkdir /mnt/cdrom 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 (Note: some systems may not recognize /dev/cdrom. If this is the case, you'll have to replace /dev/cdrom with the appropriate device name for your CD-ROM). Next, issue the following commands (again, while logged in as root): cd /mnt/cdrom/images ls You should see a file with a name similar to: mkbootdisk-1.0-1.i386.rpm Enter the filename *exactly* as shown at the end of an "rpm -Uvh". For example: rpm -Uvh mkbootdisk-1.0-1.i386.rpm The name of the package (mkbootdisk) will be displayed, followed by a series of pound signs (#). After a short time, you'll get a shell prompt. The mkbootdisk package is now installed. No you can head back to the place in this document where you left off, and create your boot diskette.