MandrakeUser.Org - Your Mandrake-Linux Knowledge Base!


 
 

* DocIndex - Administration

System Recovery I

* Rescue vs Reinstalling
* Basic Rescue Tools
* The Mandrake Linux Rescue System

Related Resources:

LIGS, 4.11
Mdk-Ref 13
Vi 101
man mount
man fsck
man init

Revision / Modified: June 17, 2002
Author: Tom Berger

 

* 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 account of time, it also prevents them to feel 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.

* section index * top

* 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.

vi

The most basic rescue tool, like it or not, is the text editor. In most cases, and on the Mandrake Linux rescue system, that's the 'vi' editor, a minimal version of 'vim'.

You open a file with 'vi' thus:

vi file

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 /some/path/file

'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 press <Z> twice. 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 <ESC> <:> <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's Vi 101 for an entertaining introduction into the Vi editor and print out Krissy J's Vi short command reference.

Notice:

  • The 'vi' command does not work on Mandrake Linux 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'.

mount

Although the current Mandrake Linux 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 in another article in 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

umount mount_directory

suffices.

fsck

'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' and 'reiserfsck'. 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 the file system 'ext2':

fsck.ext2 /dev/hdb

Notice:

  • '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'.
  • Please be aware that the man pages to these tools might not be available in case of an emergency.

By default, a file system check will be run interactively, that is every time the checker encounters an error, it asks you if to fix it. If you find this annoying, you can turn off these questions with the '-a' option in all checkers (although 'fsck.ext2' prefers '-p').

Others

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. Youwill need them some day, believe me ;-).

* section index * top

* The Mandrake Linux Rescue System

Mandrake Linux comes with a rescue system on the first CD (list of contents), 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 <F1> key and type rescue on the prompt at the bottom of the screen. Press the<ENTER> key. The rescue system will now boot from the CD, loading itself into system memory (at least 32 MB RAM needed).

In Mandrake Linux 8.2 and later, you will be presented with a text menu listing the most common tasks you'd use the rescue system for:

  1. Re-install Boot Loader. This is useful if you've recently (re-)installed another operating system which erased the boot loader installed by Mandrake Linux. This operation will revert this so that you can start every configured operating system from the boot loader menu again.

  2. Restore Windows Boot Loader. Upon installing the boot loader, Mandrake Linux 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 Mandrake Linux.

  3. 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.

  4. 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.

  5. Reboot. Well ...

  6. Doc. Read some good advice on using the rescue system.

Upon booting, the rescue system will automatically try to mount any available Linux hard disk partitions, which can then be accessed via the '/mnt' directory.
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 Mandrake Linux;
  • 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 see there's hardly an accident you can't fix with this system, provided you know how these tools work. And there's the catch: the rescue system does not contain any form of documentation, apart from the '--help' option which just displays an overview on the command's syntax, if at all.
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 online man page repository with a search interface.

Notice:

  • 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.

* section index * top

* Other rescue systems


 
Legal: All texts on this site are covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB (Tom Berger) and Mandrakesoft 1999-2002.