Lab 5
A Lesson in Disaster Recovery
As we learn the Linux operating system, our confidence will
build. With this confidence, we will be apt to try things just for
the thrill of not knowing what will happen. When this starts we
must be ready for an inevitable disaster. Don't fret or
worry! This lab will present a couple of possible situations that
you could encounter as you experiment and tinker with your system.
No working kernel
The first simulated situation is one most likely to be encountered
by those among us that will tinker with building our own kernels.
Once a kernel is built, it is placed in the /boot directory with any
other kernels used by your system. Don't destroy the working
kernels because you still need them until yours is confidently
debugged. Let's create the 'no working kernel' situation.
- Make the /boot directory your present working directory,
- list the contents of this directory,
- change the name of the kernel (vmlinuz-version_number) by
appending '.save' to it,
- make notes of what occurs when your system boots.
The problem is the Grub Boot Loader cannot find the kernel stated in
the grub configuration file. Of course, we just changed its name
by appending a '.save' to it. Well, this is an easy fix.
Follow the steps to correct this problem.
- When Grub Boot Loader displays the kernel it is trying to locate,
press the 'e' key.
- This places Grub in the edit mode. Tab to the line needing
edited. Press the 'e' key again.
- Correct the kernel name in the line to include the '.save'.
Press ENTER.
- Press 'b' to boot the system. This signals Grub to boot the
system using the modified kernel.
- Providing that you've entered the correct name for the new kernel
name, the system should boot.
- Once the system has rebooted change the name of the kernel back
to its original name.
All changes in Grub Boot Loader are temporary changes. The next
time the system is booted the same problem will occur unless you return
to the /boot directory and return the kernel to its original name.
For further details on working with the Grub and Lilo boot loaders,
refer to pages 60-69.
Bad conf files prevent a boot
Our second simulated problem will be a situation that can be
encountered because any one of the several configuration and
initialization files have errors. Our choice will be the
'grub.conf' file.
- Copy the grub.conf file to grub.conf.save.
- Using your favorite editor, open the grub.conf file as the
superuser.
- Find the line that contains 'kernel
/vmlinuz-kernel_version_number ro root=/dev/hda2' and change the line to
a comment.
- Save the 'grub.conf' file and exit your editor.
- Shutdown all open applications and reboot the system.
- What happens when the system tries to boot?
- This situation could be serious if we didn't know the strategy to
overcome it. One popular method of overcoming this situation is to
reinstall the Linux system. This is an overkill and we need to
learn a more efficient way. Remember we are working with Linux not
Windows!
- You're going to have to rescue the system. Pull out your
CDROM and insert the first CDROM in the drive. Reboot the system.
- When the CDROM is accessed, you will need to enter the rescue
mode. Follow the process outlined by the CDROM.
- The system will be booted into the rescue mode with the
filesystem mounted under /mnt.
- At the command line prompt you need to change to the grub
directory. Now we must return the 'grub.conf' file to its original
form. This is accomplished by moving the grub.conf.save to
grub.conf.
- Reboot the system and verify that your system is operating
correctly.
Forgotten passwords
A common situation that can occur to everyone of us, is a forgotten
password. Oh Dear! Do I reinstall the system?
No! Stop thinking that way! We can work through this very
easily. During the boot process you must enter the system at
runlevel 1. We used this runlevel in the previous method by
entering 'linux 1' at the boot: prompt when using the emergency boot
disk. If you permit the Grub Boot Loader to be used,
- When the Grub Boot Loader requests your input, press 'e'.
This places Grub in the edit mode.
- Three lines will appear. Select the line 'kernel
vmlinuz-kernel_version_number ro root=/dev/hda2', press 'e' again.
- This permits you to add text to the line. Add linux 1 and
press ENTER.
- Once you've returned to the original display with the changed
kernel line, press 'b'. The boot process will be initiated and the
system will be put at runlevel 1.
- At the prompt type 'passwd' and press ENTER. You'll be
prompted to enter the new superuser password. Type the password
and press ENTER.
- When prompted, retype the same password and press ENTER.
- To change the password on a user account type 'password username'
and press ENTER. You'll be prompted for the new user account
password.
- Type the new password and press ENTER. You'll be prompted
to retype the user account password. Retype the user account
password and press ENTER.
- Now we're ready to go to another runlevel. Stop you
don't need to reboot. Type 'init 3' to go to runlevel 3, type
'init 5' to go to runlevel 5. Take your pick. Remember your
passwords or you'll need to conduct this process again.