\
The Relationship between LILO, the Kernel and the Linux Root Filesystem
Linux LILO
The program, lilo, which resides on /sbin/lilo is a program that is used to install a boot loader on a boot media such as a hard or floppy drive. If the kernel is modified, lilo must be rerun. The boot loader that lilo creates accesses a map of disk blocks that are in the kernel file. BIOS is used by the boot loader to load the kernel and is therefore subject to the limitations of BIOS. Therefore any disk size limitations that lilo has is usually due to the limitations of an older BIOS. Lilo maintains a file called /boot/map by default which contains the names and locations of the kernel(s) to boot. Typing lilo -q will list the names (which are labels in lilo.conf) in this file. Lilo uses the file /etc/lilo.conf to determine what files to map. Another configuration file can be used by using the -C option with lilo. Lilo can specify a root directory for the system by using the option -r. The default boot file to be used as the boot sector is /boot/boot.b.
There are several important functions that lilo may provide to allow a system to boot.
|
|
If LILO fails when printing out "LILO", it means the following:
| LI | | Geometry mismatch or /etc/lilo/boot.b was moved without running the map installer |
| LIL | | Geometry mismatch or media (disk) failure |
Geometry failure means the number of cylinders, heads, or sectors in the BIOS configuration did not match the disk.
You can use the command "hdparm –g /dev/hda" to determine hard disk geometry.
Starting the Kernel
In order for the kernel to be properly started, it must be in the correct location as pointed to by the lilo boot loader program. This location is specified in the /etc/lilo.conf configuration as described above. Also the kernel must be properly setup after any new compile is done. The compile is done from the directory /usr/src/linux. The boot image for the new kernel should be taken from the file "/usr/src/linux/arch/i386/boot/bzImage" and renamed vmlinuz or vmlinux-2.2.12-20 or whatever it is your intention to call it. Sometimes a softlink file in /boot called vmlinuz points to the kernel that is to be run. If the copy of vmlinuz is copied from the directory /usr/src/linux, the kernel may not load properly. Sometimes the error message states that the kernel is too large.
Loading the Root Device and rdev
Once a kernel is created, it can be further configured with the utility program called "rdev". This program is used to set the image root device, swap device, and RAM disk size. Without using rdev to set the location of the root image, the kernel would need to rely upon the lilo boot loader program to tell it where it is. If this is not setup properly, you would get a message like "kernel panic, unable to mount root device".
In a kernel bootable image, there are several pairs of bytes that specify the following characteristics. These pairs of bytes start at decimal offset 498 in the kernel image.
498 Root flags (One sets the root FS to mount in read or read-write mode)
500-502 Reserved
504 RAM disk size
506 Video mode
508 Root device
510 Boot Signature
4. The swap device
To get help using rdev, type "rdev –h". Below are formats for making adjustments to the kernel image:
| rdev vmlinuz /dev/hda2 | | Sets the kernel image named vmlinuz to mount /dev/hda2 as root filesystem. |
| rdev -s vmlinuz /dev/hda3 | | Sets the kernel image to mount /dev/hda3 as the swap device. |
| rdev -r vmlinuz 627 | | Set the RAMDISK size in kilobytes |
| rdev -v vmlinuz 1 | | Set the bootup video mode –3=ask, -2=extended VGA, -1=Normal VGA, 1=key1 as if 0 pressed at the prompt, 2=key2 as if 1 were pressed. |
| rdev -R vmlinuz 1 | | Set the rootflags to read only status, a 0 would mount read-write. This means the root partition is read-only at boot time so the filesystem can be checked before being mounted |
|