System Recovery I
- Rescue vs Reinstalling
- Basic Rescue Tools
- The Mandrakelinux Rescue System
Rescue vs Reinstalling
Very often less experienced Linux users counter system problems with the troubleshooting technique they've learned on other operating systems: they reinstall the whole operating system.
This of course does not only cost quite a massive amount of time, it also prevents them from feeling really secure with the system, all the more since these users usually do not keep backups.
There are very few compelling reasons to ever reinstall Linux, like massive file system corruption or a hard drive failure. You can repair everything else either from within the system or from outside (via a network connection or a boot disk/CD). In contrast to other operating systems all configuration files are in plain text and can be edited with the most simple text editor. Furthermore you can reinstall, upgrade or downgrade every part of the system, since Linux only needs a minimal set of files to provide the basic functions of an operating system.
Being able to repair a system is what makes you an administrator, it is arguably the most important step from being controlled by your system to take control of it.
Basic Rescue Tools
There is nothing wrong with using graphical tools to configure and administer your system. These tools often make it easier to handle complex tasks and to get things working.
In a case of emergency, however, you will most likely not be able to access them. That's why Linux administration requires at least some rudimentary knowledge of using the 'traditional' command line Unix tools.
The most basic rescue tool, like it or not, is the text editor. In most cases, and on the Mandrakelinux rescue system, that's the 'vi' editor, a minimal version of 'vim'.
You open a file with 'vi' thus:
If the file isn't in the current directory, you have to put the path to that file in front of the file name:
'vi' now displays the file. To edit the displayed file, press the < i > key. You can then move around with cursor keys insert and delete text with the usual keys.
To save an edited file, press the < ESC > key and then either press < Z > twice, or < : >< w >< q >< ENTER > one after the other. Notice that 'vi' makes a difference between capital and small letters, so make sure you press a capital 'Z' twice here.
To quit editing a file without saving the changes you made to it, press these keys one after the other < : >< q >< ENTER >.
Of course there's much more to 'vi' and 'vim'. Even if you do not adopt it as your favorite editor, you should get comfortable with using its basic functions, since this training will be of use to you some day. You might want to read Vikram Vaswani'sfor an entertaining introduction into the Vi editor or a .
- The 'vi' command does not work on Mandrakelinux when the 'vim-enhanced' package is installed and you are working on a partition which only contains the root directory with no other partitions mounted.
Use vim-minimal instead or run
update-alternatives ––config vi
to set the name of the executed binary back to '/bin/vim-minimal'.
Although the current Mandrakelinux rescue system mounts your Linux partition automatically when started, there might be circumstances when you have to mount or unmount partitions or external media by hand, e.g. when your are using an older release or when your machine doesn't have a bootable CD drive, if you need to do a file system check or need access to external media.
Mounting is discussed in depth inin this section, but here are the basics.
In order to mount a medium, you need to know its device file name. If it is a partition on a hard disk, it's pretty easy to find out:
fdisk -l /dev/device
device stands for the device file name of the hard disk. In most case, it will be 'hda', the first IDE hard disk on the first IDE channel:
fdisk -l /dev/hda
This will list all partitions on that disk along with their device names. The second hard disk ('slave' on the first IDE channel) would be 'hdb', the first disk on the second channel 'hdc' etc. Notice that if you've got your hard disk connected to an UDMA-100 controller (on-board or card), the name of the first hard disk is 'hde'.
For more device file names read the article linked to above.
To mount a medium, you type
mount /dev/device mount_directory
mount_directory can be any existing directory on the current medium, preferably an empty one. To unmount a medium, a simple
'fsck' a utility for performing file system checks and repairs. You start a file system check this way:
fsck -t file_system device_file
file_system has to be substituted by the file system on the partition you want to check. In contrast to 'mount', 'fsck' can't figure out the file system type on its own.
Instead of using the '-t file_system' option, you can also call the file system specific variants of 'fsck' directly: 'fsck.ext2', 'fsck.jfs', 'fsck.xfs' (XFS) and 'reiserfsck' (Reiser Filesystem). This is actually the preferred way, since it eliminates the chance of getting options to 'fsck' and 'fsck.fs' mixed up.
Thus, to check the second primary partition on the first IDE hard drive which has another file system :
- 'fsck' should only be run on unmounted file systems.
- 'fsck.ext2' will also work on 'ext3' file systems.
- By default 'fsck.ext2' will not check a file system which has been cleanly unmounted. To force it to do a check, use the '-f' option.
- The man page to 'fsck.ext2' is man e2fsck.
- 'fsck.xfs' doesn't do anything. To repair an XFS, use 'xfs_repair'.
- 'fsck.vfat' needs the option '-a' (automatic) set to make a repair, or '-r' for interactive mode.
- 'fsck.vfat -u filename' you can restore a deleted file
- Please be aware that the man pages to these tools might not be available in case of an emergency.
- If nothing works, you can use
- XFS: You have to install the proper package xfsprogs before this will work. Do not forget to make a backup copy, e.g. with xfsdump.
Make yourself familiar with these commands: 'mv', 'cp', 'rm', 'ls', 'cd', 'grep' and 'less'. This doesn't mean you should learn their man pages by heart, but you should know what they do and how to handle them. You will need them some day, believe me ;-).
The Mandrakelinux Rescue System
Mandrakelinux comes with a rescue system on the first CD, introduced in release 7.1. In case your CD-R drive isn't bootable, boot from a boot floppy (images are in the '/images' directory of the first CD).
To start this rescue system, press the key and type rescue on the prompt at the bottom of the screen. Press the key. The rescue system will now boot from the CD, loading itself into system memory (at least 32 MB RAM needed).
In Mandrakelinux 8.2 and later, you will be presented with a text menu listing the most common tasks you'd use the rescue system for:
- Re-install Boot Loader. This is useful if you've recently (re-)installed another operating system which erased the boot loader installed by Mandrakelinux. This operation will revert this so that you can start every configured operating system from the boot loader menu again.
- Restore Windows Boot Loader. Upon installing the boot loader, Mandrakelinux makes a backup copy of the previous boot code. This operation writes this backup copy back to the boot sector, thus erasing the boot loader installed by Mandrakelinux.
- Mount your partitions under /mnt. Use this if you want to access your Linux partitions on the hard drive from the console. The rescue system will make an educated guess which partitions to mount to what directories.
- Go to console. Starts a console without mounting any partitions. Might be useful if the rescue system can't figure out your partition scheme or if you have several Linux installations.
- Reboot. Well ...
- Doc. Read some good advice on using the rescue system.
The rescue needs only system memory to work, which means you can remove the CD after boot (e.g. to use the drive to mount another CD).
The software contained in the rescue system allows you to
- delete, move, copy, (un)archive, (de)compress and create files, directories and symlinks to files;
- display, edit and create text files (including hex files);
- check and repair every file system available with Mandrakelinux;
- create, delete, resize (ext2 only) and repair partitions, partition tables and boot sectors;
- mount any kind of medium;
- establish an Ethernet network connection and telnet or ftp into another machine;
- install RPM packages;
- load and unload kernel modules and
- do all that with a keyboard map and console font of your choice.
You are not supposed to learn the options of these programs by heart, instead get a good and short command reference, like Hekman's 'Linux in a Nutshell' or Petron's 'Essential Reference'. If you can't spare the money, print out the man pages to the most important commands. There's also an with a search interface.
- USB-only keyboards do not work. If your USB keyboard comes with a second PS/2 plug, put that in.
- No mouse support.
- If you have more than one Linux installation, use the 'mount' command to make sure that the rescue system has mounted the right partitions.
- You are root during your entire 'rescue' session. Be careful.
Revision / Modified: June 17, 2002
Author: Tom Berger
Legal: This page is covered by the. Standard disclaimers of warranty apply. Copyright LSTB and Mandrakesoft.
Version 1.15 last modified by on 03/05/2007 at 02:38