![]() |
|
|
|
|
|
An in-depth look at LILO
By Trevor Warren <trevor@freeos.com>
In a previous article, we saw how versatile the boot loader 'LILO' was. This session we get more technical and look at the internals of LILO, its primary boot time operation, functionality and a few nifty little arguments that can help us tune up our LILO installation. One of the plus points of LILO is that it is filesystem independent. It is able to boot operating systems from Microsoft, OS/2, SCO Unix, Unixware, PC-DOS to Linux. LILO has the capability to handle a maximum of 16 different boot images. Not only can LILO be used as the primary boot manager, with LILO written onto the MBR, but also as a secondary boot loader with LILO written to the boot sector of an extended partition. There are a whole series of permutations and combinations to booting into their system, using LILO. So, LILO should be able to boot your system regardless of the configuration. Let's take a general look at how a booting procedure really goes about. Data on our hard drives is laid out in a very precise and accurate manner and structured into "Tracks" and "Sectors". "Tracks" and "Sectors" are the fundamental locks that define the storage of data on the storage media. Consider a storage device like a hard drive. This hard drive on formatting consists of various tracks and sectors. ----------------------------- Refer to the figure above. At the beginning of the hard drive, we have the boot sector. Immediately after the boot sector lies the File Allocation Table (FAT) and probably some other irrelevant data. Rest of the area on the hard drive is for the purpose of storing data. Hard drives are generally broken into primary and extended partitions. Primary partitions are bootable partitions and can be made to boot through any boot loader. Many BIOS' prevent booting off logical partitions. Linux has the capability to support a maximum of four primary partitions. If additional partitions are required, one of the partitions can be made an extended partition where additional logical partitions created. One important point to note is that the partition tables of some logical partitions are not accessible as the first block of some devices, while in the main partition table all boot sectors and partitions tables of the extended partitions are. Partition tables are generally stored in the boot sector of the partition and normally only the partition boot sector of the entire disk is usable as the boot sector. This is called the Master Boot Record (MBR). LILO can be made use of in the following instances. 1. Writing to the boot sector of the first hard disk. LILO can't be made use of in the following instances. 1. Writing it to a SWAP partition. Various programs that make up your Boot Loader Let's now look at the various programs that are a part of the LILO installation. The MAP installer: This program puts all the files belonging to LILO in the appropriate places and also to record the location of information, which will be needed by LILO during boot-up. This program would be /sbin/lilo and has to be run every time there is a change in the configuration file or if there is a new kernel. /boot/*.*: Various other files required by LILO during the booting sequence are stored in the /boot directory. Some of the more important files are the boot loader and the map file. Apart from these you are likely to find the stock kernel here. The map file is an important file where the map installer records the location of the new kernel. Boot Loader: The boot loader is by far the most important component. The boot loader is loaded into memory by the BIOS. This then loads the kernel or possibly the boot sector of other operating systems. The boot sector containing the first part of the boot loader is loaded into memory which then loads the second part of the boot loader which is generally stored in the file /boot/boot.b. The boot loader then starts the kernel. Let's look at a few boot combinations. When booting from a floppy disk, the very first sector of the disk is loaded by the BIOS into memory. This particular area of the floppy disk on bootable floppies is supposed to contain a program that will boot the respective operating system. Similar to this procedure of booting a floppy disk, let's assume that LILO has been written on the MBR (Master boot Record) of the hard disk of a dual boot system. During the booting operation the MBR is loaded into memory, which then executes it's respective operating functions and provides the user with a choice of booting into any operating system of their choice. To get the figures right, the first 446 Bytes of MBR are made use of by the Boot Loader and the rest 64 Bytes of the data are related to information about the partition table. Making a backup copy of your MBR on a floppy disk This is just a precaution. LILO is quite safe to use so you probably won't need this tip. The command for the backup is as following. bash# dd if=/dev/hda of=/dev/fd0 bs=512 count=1 "dd" is the command used to write raw data onto any storage media. This particular command tells 'dd' to copy the first 512 Bytes of information from the hard drive /dev/hda (MBR) to the floppy disk (/dev/fd0). Restoring the old MBR is just about turning the parameters around. The command is as follows. bash# dd if=/dev/fd0 of=/dev/hda bs=446 count=1 Getting rid of LILO For DOS users, restoring your MBR and getting rid of LILO is just one simple command. c:> fdisk /mbr Getting back LILO What happens quite often is that LILO might get wiped out of the MBR. Re-installing Windows is one of the most common reasons for this. Whatever the reason, you should know how to recover and re-install LILO. Get a hold of a installation CD. Just about every Linux distribution these days is available on bootable CD's. We've had terrible times searching for a working clean floppy for a boot disk and we don't recommend boot disks. If you do have good disks then use the images on your distribution CD. SuSE provides a image of a rescue disk on their CD. Most distributions provide such images. A good place to look for boot images is www.bootdisk.com. Download one, follow the instructions and you'll soon have a working boot disk. Under Linux, use "dd if=/cdrom/disks/rescue of=/dev/fd0" to create a rescue floppy disk. Under DOS use rawrite.exe (included in most distributions) and then do "rawrite image-name a:". If you're booting off the CD then you might have to do some work after you boot. Red Hat has a rescue mode that you select after booting. Under SuSE we have to boot into the installation and then use the ctrl+alt+fn key to locate a shell prompt. You can use this shell prompt to continue with the recovery. Boot in and enter the following at the prompt. mkdir mount First, create a mount point. The root partition of your lost Linux installation will be mounted here. mount /dev/hda6 mount Mount the root filesystem under "mount". If /boot is a separate partition then mount that under "mount/boot". mount /dev/hda1 mount/boot The "/boot" partition has been mounted under "mount/boot" chroot mount Run a shell with your root directory as "mount". What this does is that "mount" will become your root directory as referenced by "/". So, now when you say "cd /boot", you'll actually be changing into "mount/boot". /sbin/lilo Re-run LILO. This will install LILO back to the MBR. At next boot the LILO prompt will be back.
Other articles by Trevor Warren
Current Rating: [ 7.11 / 10 ]
Number of Times Rated: [ 36 ]
|
|
|
© 1998-2004 FreeOS Technologies (I) Pvt. Ltd. All rights reserved.
[Privacy Policy]
![]() |