Red Hat Linux Unleashed rhl04.htm

Previous Page TOC Next Page



4


LILO


Whenever you hear about Linux, you'll also hear about LILO. LILO is the boot loader used by Linux to load the operating system kernel. Whenever the Linux kernel is changed or moved, LILO must be invoked to rebuild a map of the kernel locations. LILO is versatile; it can boot Linux kernels from any type of file system, including floppy disk, as well as from other operating systems.

This chapter looks at LILO, the way hard disks are laid out with Linux, the boot process, and the most common boot processes and LILO's interactions with each. This should help you install and use LILO efficiently and effectively.

Using LILO to Boot Off the Hard Drive


LILO (which means LInux LOader) is a bit tricky to use if you are not familiar with it and its purpose. You need to install the LILO program, which changes the boot sector of your hard drive to allow you to choose between a DOS or a Linux partition as the boot source partition. LILO is included with Red Hat Linux and is installed automaically when you load the system from CD-ROM.

Some of the features of LILO include the following:

Using LILO may seem risky at first; it can ruin your hard drive or leave you with a system that you cannot boot. To prepare yourself for this mishap, keep a boot disk handy. Also, you have to do this installation as root, so be careful.

If you have already installed Red Hat Linux, the LILO files will exist on your hard drive. If you are about to install Red Hat Linux, the LILO installation routine will be activated automatically as part of the installation process. If you want to redo the LILO system at any time, though, you can run the program /sbin/liloconfig.

The liloconfig program is easy to use and asks several questions about your system. The sheer number of possibilities cannot be completely covered here, but here are the terms with which you must be familiar:

The liloconfig program asks you where you want to install LILO. If you are running multiple operating systems and plan to switch between them often, try installing on the Linux partition superblock. If you will use Linux primarily or only, install on the Master Boot Record. You will then be asked about the ability to load other operating systems from the boot prompt, and you get to identify each operating system and provide a name for it. This lets you start DOS, for example, from the boot prompt by entering the name you assigned to DOS partition.

After the liloconfig program has run, it will create a file called lilo.conf for you in the /etc directory. If you already have this file in your /etc directory, you can edit it manually using any ASCII editor. Of course, depending on how your system is set up, the contents of your Linux installation may vary. A sample lilo.conf file for a system containing both DOS and Linux looks like this:


boot=/dev/hda

map=/boot/map

install=/boot/boot.b

prompt

timeout=50

image=/vmlinuz

root=/dev/hda2

label=linux

other=/dev/hda1

label=dos

table=/dev/hda

In this lilo.conf file, you can see two different kernels that can be booted from /dev/hda. The first image is the default image, called vmlinuz. The other image is labeled DOS for the DOS partition. Typing dos at the boot prompt will boot this partition.

LILO Command-Line Arguments


The LILO configuration is written to disk using the /sbin/lilo command. The /sbin/lilo installer accepts several command-line options. A few of the more usual ones are listed here.


Configuration Parameters


The /etc/lilo.conf file can have the following parameters. All of these can be set from the command line, but storing them in a configuration file is more reliable. The following options are available to you:



fix-table does not guarantee that other operating systems might not attempt to reset the address later. It is also possible that this change has other, unexpected side effects. The correct fix is to repartition the drive with a program that does align partitions to tracks.

The kernel configuration parameters append, ramdisk, read-only, read-write, root, and vga can be set in the options section. They are used as defaults if they aren't specified in the configuration sections of the respective kernel images.

If the option -q is specified on the command line, the currently mapped files are listed. Otherwise, a new map is created for the images described in the configuration file /etc/lilo/config and they are written to in the boot sector.

The boot Prompt


When the system boots up, after the keyboard test, press and hold down one of any one of these keys: Alt, Shift, or Ctrl (or you can set the Caps Lock or Scroll Lock key). If any of these keys are pressed, LILO displays the boot: prompt and waits for the name of a boot image. Pressing the Tab key or typing ? gives you a list of names recognized by LILO. If you do not press any of these keys, LILO will boot up the first it finds in the lilo.conf file kernel (in this case, vmlinuz.cd) if there is no timeout specified in the /etc/lilo.conf file.

LILO can also pass command-line options to the kernel. Command-line options are words that follow the name of the boot image and are separated by spaces. Currently, the kernel recognizes the options root=<device>, ro, and rw, and all current init programs also recognize the option single, which boots the system in single-user mode. This bypasses all system-initialization procedures and directly starts a root shell on the console. Multiuser mode can be entered by exiting the single-user shell or by rebooting.

The option vga is processed by the boot loader itself. The option vga=<mode> alters the VGA mode that was set at startup. The legal values for mode are NORMAL, EXTENDED, ASK, or a decimal number for the BIOS mode command. You can get a list of available modes by typing vga=ask and pressing Enter.

The root=<device> option changes the root device. This overrides settings that may have been made in the boot image and on the LILO command line.

Depending on the kernel configuration, some special configuration options for nonstandard hardware might be recognized as well. Some of these boot prompts include the following :

The parameters for each type of device will come with their documentation, so do not assume anything. Use only specified values. If you do follow instructions, you may wind up causing irrecoverable errors, which may lead to a corrupt file system.

Uninstalling LILO


In order to keep LILO from being invoked when the system boots, its boot sector has to be either removed or disabled. All other files belonging to LILO can be deleted after removing the boot sector, if desired.

LILO 0.14 (and newer) can be uninstalled with the lilo -u command.

If LILO's boot sector has been installed on a primary partition and is booted by the standard MBR or some partition-switching program, it can be disabled by making a different partition active. MS-DOS's FDISK, Linux's fdisk, or LILO's activate can do that.

If LILO's boot sector is the Master Boot Record (MBR) of a disk, it has to be replaced with a different MBR, typically MS-DOS's standard MBR. When using MS-DOS 5.0 or above, the MS-DOS MBR can be restored with FDISK /MBR. This alters only the boot loader code, not the partition table. LILO automatically makes backup copies when it overwrites boot sectors. They are named /etc/lilo/boot.<nnnn>, with <nnnn> corresponding to the device number—that is, 0300 is /dev/hda, 0800 is /dev/sda, and so on. Those backups can be used to restore the old MBR if no easier method is available.

The commands are


dd if=/etc/lilo/boot.0300 of=/dev/hda bs=446 count=1

or


dd if=/etc/lilo/boot.0800 of=/dev/sda bs=446 count=1

respectively.



Some other operating systems (such as MS-DOS 6.0) appear to modify the MBR in their install procedures. It is therefore possible that LILO will cease to work after such an installation and Linux has to be booted from floppy disk. The original state can be restored by either rerunning /etc/lilo/lilo (if LILO is installed as the MBR) or by making LILO's partition active (if it's installed on a primary partition).
Typically, the new operating system then has to be added to LILO's configuration (and /etc/lilo/lilo has to be rerun) in order to boot it.



Map Installer Errors


Some messages that indicate common errors when installing the maps are as follows:


LILO Error Codes


When LILO loads itself, it displays the word LILO. Each letter is printed before or after performing some specific action. If LILO fails at some point, the letters printed so far can be used to identify the problem. This is described in more detail in the technical overview.

Note that some hex digits may be inserted after the first L if a transient disk problem occurs. Unless LILO stops at that point, generating an endless stream of error codes, such hex digits do not indicate a severe problem. The following is the list of error messages you can see:

There are also BIOS error codes that you might get while loading LILO. These are listed in Table 4.1.

Table 4.1. BIOS error codes.

Code Value
0x00 Internal error. This code is generated by the sector-read routine of the LILO boot loader whenever an internal inconsistency is detected. This might be caused by corrupt files; try rebuilding the map file.
0x01 Illegal command. This shouldn't happen.
0x02 Address mark not found. This usually indicates a media problem. Try again several times.
0x03 Write-protected disk. This shouldn't happen.
0x04 Sector not found. This typically indicates a geometry mismatch. If you're booting a raw-written disk image, verify whether it was created for disks with the same geometry as the one you're using. If you're booting from a SCSI disk, you should check whether LILO has obtained correct geometry data from the kernel or whether the contents of your /etc/lilo/disktab file correspond to the real disk geometry. Removing compact may help too.
0x06 Change line active. This should be a transient error. Try booting a second time.
0x08 DMA overrun. This shouldn't happen. Try booting again.
0x09 DMA attempt across 64KB boundary. This shouldn't happen. Try omitting the -c option.
0x0C Invalid media. This shouldn't happen and might be caused by a media error. Try booting again.
0x10 CRC error. A media error has been detected. Try booting several times, running the map installer a second time (to put the map file at some other physical location or to write good data over the bad spot), mapping out the bad sectors/tracks, and, if all else fails, replacing the media.
0x20 Controller error. This shouldn't happen.
0x40 Seek failure. This might be a media problem. Try booting again.
0x80 Disk timeout. The disk or the drive isn't ready. Either the media is bad or the disk isn't spinning. If you're booting from a floppy, you might not have closed the drive door. Otherwise, trying to boot again might help.

Using BOOTLIN Instead of LILO


The BOOTLIN package uses the DOS MBR to boot off the hard drive. To install this package, you must take the following steps:

  1. From within Linux, copy a bootable kernel to your DOS partition.

  2. Edit config.sys on the DOS partition to include two files: BOOT.SYS and BOOTLIN.SYS. The README files for these packages tell you how.

  3. Reboot.

Now when you reboot, the BOOT.SYS and BOOTLIN.SYS files will boot into Linux for you.

To get back to running only DOS, remove the BOOTLIN.SYS and BOOT.SYS from your config.sys file.

The disadvantage of this approach is that you are limited to having DOS on your hard drive.

Restoring the MBR


If you want to restore the MBR to the original DOS MBR, you can use the following procedure:

  1. Boot from a DOS floppy.

  2. Run fdisk /MBR from the DOS prompt. (You can also use the command SYS C:.)

  3. Reboot.


Summary


This chapter covered the topic of installing, configuring, and using LILO. It also covered some of the basic errors you can face and how to set up LILO using the liloconfig utility. The information you have learned from this topic should get you started in setting up LILO to boot Linux on your machine off the hard drive.

Previous Page Page Top TOC Next Page