Chapter 14. Troubleshooting (2.214)

Revision: $Revision: 1.6 $ ($Date: 2007-01-18 14:45:53 $)

This topic has a total weight of 7 points and contains the following objectives:

Objective 2.214.1; (Not Implemented by LPI)

This objective was not defined by LPI.

Objective 2.214.2 Creating recovery disks (1 point)

Candidate should be able to: create both a standard bootdisk for system entrance, and a recovery disk for system repair.

Objective 2.214.3; Identifying boot stages (1 point)

Candidate should be able to: determine, from bootup text, the 4 stages of boot sequence and distinguish between each.

Objective 2.214.4; Troubleshooting LILO (1 point)

Candidate should be able to: determine specific stage failures and corrective techniques.

Objective 2.214.5; General troubleshooting (1 point)

A candidate should be able to recognize and identify boot loader and kernel specific stages and utilize kernel boot messages to diagnose kernel errors. This objective includes being able to identify and correct common hardware issues, and be able to determine if the problem is hardware or software.

Objective 2.214.6; Troubleshooting system resources (1 point)

A candidate should be able to identify, diagnose and repair local system environment.

Objective 2.214.7; Troubleshooting network issues (1 point)

A candidates should be able to identify and correct common network setup issues to include knowledge of locations for basic configuration files and commands.

Objective 2.214.8; Troubleshooting environment configurations (1 point)

A candidate should be able to identify common local system and user environment configuration issues and common repair techniques.

Creating recovery disks (2.214.2)

Revision: $Revision: 1.8 $

Candidate should be able to: create both a standard bootdisk for system entrance, and a recovery disk for system repair.

Key files, terms and utilities include:

/usr/sbin/rdev
/bin/cat
/bin/mount(includes -o loop switch)
Any standard editor
/sbin/lilo
/bin/dd
/sbin/mke2fs
/etc/fstab, /etc/inittab
/usr/sbin/chroot
Familiarity with the location and contents of the LDP Bootdisk-HOWTO (http://www.ibiblio.org/pub/Linux/docs/HOWTO/Bootdisk-HOWTO)

Resources: BootFAQ; the man pages for the various commands.

Why we need bootdisks

A bootdisk is a small Linux system on a diskette. You can boot a kernel from it, hence the name. The kernel will mount a root filesystem, which typically is either stored on the same diskette or on a separate root disk. That filesystem contains a number of necessary files and devices, and a set of software tailored for a specific task. You can expect basic commands like /bin/mount, /bin/sh or /bin/bash to be in the bootdisk's root file system and basic configuration files like /etc/inittab - just enough to satisfy the needs the bootdisk was intended for.

The software found on a bootdisk is mostly used to perform a subset of system maintenance functions. Often, the boot disk's root filesystem contains software to recover from system errors, for example to enable you to inspect and repair a damaged system. Sometimes they are used to perform a very specific task, for example to enable easy software upgrades for large quantities of MS-Windows laptops[26].

Since there is just a limited amount of data you can store on a diskette, often compression techniques are used to create a compressed image of the filesystem on disk. In these cases the kernel will decompress the image into memory and subsequently mount it. The kernel needs to be built with RAM-disk support to enable it to do this. In some cases the available space is insufficient for both the kernel and its root filesystem. In these cases, the kernel is put on one disk (the boot disk) and the (compressed) root filesystem on another (the root disk). Sometimes one or more utility disks are used to store additional data, for example additional utilities that do not fit on your root disk.

The Bootdisk-HOWTO contains an excellent and very detailed description on how to build various types of boot and root disks. In the sections below we give an overview of the material presented there. Please refer to the HOWTO for additional information.

Create a bootdisk

To build a bootdisk, you will need to ..

  • select or build a kernel

  • copy the kernel to a floppy disk either by:

    • using LILO or

    • using dd

  • create and populate a root filesystem

  • decide whether or not to use a separate disk for the root filesystem

  • compress the root filesystem

  • copy the root filesystem to floppy disk

  • set the ramdisk word

Each of these steps is outlined below. More specific details can be looked up in the FAQ.

The boot disk typically contains the kernel to boot. Hence, you first need to determine the functionality your boot-kernel will need and either build a new kernel or select one that was built before and matches the specifications. For example, to create a bootdisk to be used for checking filesystems, you need to have a kernel that recognizes the proper filesystems. However, it does not necessarily need networking functionality. In some cases it suffices to copy over your existing kernel, but in many cases your default (compressed) kernelimage will be too bloated to fit on a diskette, especially if you aim to build a combined boot/root disk. The kernel building process is described in more detail in the section called “Kernel Components (201.1)” and on.

After selecting/building the kernel you need to copy it on to the boot disk. You can either use LILO or copy over the kernel using dd.

  • The method which uses LILO consumes more disk space, but adds some flexibility, since you will be able to specify extra parameters during boot. You will need to create a small filesystem on the boot disk for LILO, just big enough to contain the kernel and 50 blocks worth of additional space for inodes. You then create a filesystem on the disk, using mke2fs, and fill it with some device- and configuration files, see the FAQ for details. Then you run lilo on it.

  • The other method uses dd to copy over the kernelimage to the disk. In this case you do not need to make a filesystem, but need to configure the kernel itself to instruct it where to find its rootdevice. This can be done using the rdev command.

In both cases next you need to set a value in the so-called ramdisk word in the kernel. This is a well defined location in the kernel binary that is used to specify where the root filesystem is to be found, along with other options. The word consists of 16 bits. The first 11 bits are used to set the offset (specified in 1024 byte blocks) where on the disk the root filesystem image will be stored. If bit 15 is set the kernel will prompt you for a diskette before trying to mount the root filesystem. This enables you to use a separate root disk. Bit 14 is used to signify that a RAMdisk should be used. You will need to calculate the value for the RAMDISK word by hand and set its value via the rdev command.

The creation of a root filesystem is by far the most complex part of the job. It requires setting up a partition somewhere (a physical partition, a file mounted via the loopback interface or a ramdisk), zeroing it out to remove random garbage (which allows for optimal compression later), creating a filesystem on it, mounting it, populating it with the files you want, unmounting it, compressing it and finally copying the compressed image onto a floppy. You will need to ensure the consistency of the filesystem contents, for example make sure that all (dynamic) libraries that are needed are available and all necessary devices are created. All of these steps are described in more detail in the FAQ.

Big files have little files upon their back..

Linux makes it fairly easy to create a filesystem within/on a file instead of on a disk or ramdisk: it uses loopback devices. You could create an iso9660 CD ROM image (typically using the mkisofs command) and mount it without having to burn it to CD first by using a loopback device. A less commonly known technique uses a plain file. To make this work you need to create an zeroed out file first:

dd if=/dev/zero of=fsfile bs=1k count=100

This creates a file that contains 100K of zero bytes, named fsfile. Next, you need to associate one of the loopback devices with that file. This is done using the losetup command:

losetup -e none /dev/loop0 fsfile

The -e none is default and specifies that encryption should not be used in this case (check out the manual page for losetup(8) for more details). Now, you can make a filesystem on it, in this case an ext2 filesystem:

mkfs -t ext2 /dev/loop0 100

Next, mount this newly created filesystem somewhere in your hierarchy, let's say on /mnt:

mount -t ext2 /dev/loop0 /mnt

You can use this filesystem any way you want to. To unmount it, use:

umount /dev/loop0
losetup -d /dev/loop0

There are various software packages available to aid the creation of boot- and rescuedisks. Using these packages you can just specify a set of files for inclusion and the software automates (to varying degrees) the creation of a bootdisk. Some of these packages enable creation of very compact, yet rich micro-distributions that contain hundreds of commands and a kernel on one diskette.

initrd

Newer kernels (as of 2.0) allow a kernel to boot in two phases. Initially, the kernel can load an initial ramdisk image (hence the name initrd) from the boot disk, which contains a root filesystem and a program (/linuxrc) to be run. linuxrc can perform various (interactive) tasks, e.g. ask the user for additional configuration options. It often is used to add additional modules in a bare-bone kernel. After this initial program exits, the kernel continues loading the real root image and booting continues normally.

Create a recovery disk

A recovery (or rescue-) disk is in fact just a boot/root disk and is created likewise (the section called “Why we need bootdisks”). But besides the generic software that makes up a bootdisk, it also contains information specific for your distribution or system. It is used to recover from fatal system crashes and can be used to restore your systems functionality, for example by providing software to restore backups (cpio, tar). It usually contains information about your system like partition information and a kernel specific to your systems hardware. Most Linux distributions offer you the option to create a rescue disk during system installation.



[26] This actually occurred a few years ago, when a large company needed to upgrade the OS on hundreds of MS-Windows based laptops. A special Linux boot disk was created, which contained stripped down versions of Linux, the PCMCIA tools and the Samba server. By booting that disk in a networked laptop it became a sambaserver that had the harddisk of the laptop mounted, ready for updates.

Copyright Snow B.V. The Netherlands