Troubleshooters.Com and T.C Linux Library Present

Litt's Lilo Lessons

Copyright (C) 1998, 1999 by Steve Litt, All rights reserved. Material provided as-is, use at your own risk. 


Here are some Lilo lessons I learned the hard way. Maybe you're smarter than I was, but in case you make the same silly mistakes I made, here are some tips that can save you, oh, say 10 hours. The granddaddy of all LILO tips is this:

LINUX DOESN'T GIVE A HOOT WHAT YOUR LILO.CONF SAYS AT BOOT TIME!!

Did I shout loud enough? Hope so, because the person without that concept walks the trail of tears.

File /etc/lilo.conf has one major use. It's what program /sbin/lilo reads in order to update the boot sectors. The information available to lilo when lilo is run gets transferred to the boot sector. It does not matter whether that same info is available at boot time -- it's already in the boot sector. This document will discuss only those configurations that keep the boot info in the MBR (Master Boot Record), but the principles are the same.
 

Disclaimer

I wrote this as I learned it, so there are probably some errors. Feel free to write me about any errors. I believe that this material will be helpful, but of course it's as-is, so use it at your own risk.

Note: Windows requires the C: drive be installed on a primary partition. If you believe you'll *ever* want Windows on a machine, allocate a 500MB or more  primary partition to be used later as the C: drive, *before* creating Linux drives other than your hda1 /boot.  Use Dos's fdisk to create the Windows C drive partition as a primary partition. Then go about your Linux installs. Note that dos fdisk can corrupt existing Linux partitions, a situation which may or may not be correctable with a rescue disk expedition.  Note that Win drives can be placed on virtual drives on the extended partition produced by Linux' fdisk. However, I cannot guarantee that any of the drives mentioned in this note will not "leak" over to the linux partitions and corrupt them.
Windows multi-boots can get nasty, especially if Windows is installed after the fact. Do it at your own risk.

What Doesn't Work

Look through any literature including the lilo man pages and you'll see setups like this:
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
vga = normal
prompt
timeout=50
image=/boot/vmlinuz-2.2.5-15
        label=rh
        root=/dev/hda2
        read-only

image = /boot/vmlinuz-2.2.5-modular
        label = cald
        root = /dev/hda5
        read-only

image=/vmlinuz
        label=deb
        root = /dev/hda6
        read-only                     

Looks good, doesn't it? The root= line of each image points to just the place where image can be found -- obviously the image is relative to it's root. Why, it makes perfect sense. But it's dead wrong!!! The image= lines must be modified so they point to legitimate mounts of their respective distro kernels. And the contents of lilo.conf matter *only* at the instant LILO is run. Read on...

What's LILO?

LILO is a program (more accurately a group of programs) designed to move information to and from boot sectors. The information to move there is kept in a configuration file. This config file's sole purpose in life is to supply LILO with data to write to the boot sector. It **DOES NOT** perform any function at boot time. The mounts implied by the configuration file need only be in effect when lilo is run, not at boot time. The default configuration file is /etc/lilo.conf. Any other config file must be specified to lilo with the -C option. Lilo is run like this:
# lilo
Or, if you're using a different configuration file, do it like this:
# lilo -C /home/myuid/mylilo.conf

Multi-booting Linux Distros

The fun begins when you have Red Hat, Caldera, Debian and Slackware on a single computer, and want to boot between them. The best way to accomplish this is:
  1. Create a /boot partition
  2. Install Windows if you must
  3. Install your "best" distro, being sure to make a boot disk for it.
  4. Install your other distros
  5. Boot back to your "best" distro.
  6. Mount the roots of the other distros
  7. Copy image specifics from other disto lilo.confs to your "best" distro lilo.conf
  8. Modify "best" lilo.conf to reflect your present mounts and distro labels
  9. run the lilo command with no arguments to update your MBR
  10. Reboot and test all distros.
  11. Fix as necessary


A Windows client needs an IP address. But it doesn't need the IP assignment to be hard-coded into the machine's configuration. Instead, it can receive its IP address from a server. The most common way to do that is via DHCP, standing for Dynamic Host Configuration Protocol. The DHCP server can be on an NT machine, or it can be on your Linux machine. This tutorial explains enabling your Linux machine to be a DHCP server.
 

Create a /boot partition

Many BIOSes will fail to boot (at least from LILO derived boot sectors) if any of the code resides beyond cylinder 1024. For that reason it's best to have a partition right at the start of /dev/hda to mount to /boot. Be liberal allocating its space. To calculate its space, decide the max number of distros (excluding Windows) that will reside on the machine simultaneously, add one to that number, and multiply that by 15 meg. So if you'll have Red Hat, Caldera and Debian, and you want to have the option of later adding one additional partition that you test distros on, you'll need to make hda1 ((3+1)+1)*15meg = 75meg.

Use a Linux partition software to create this partition. The easiest way I've found is to boot the Red Hat installer, go thru the install to partitioning, choose fdisk over Disk Druid, create hda1 for the correct amount of space, write it back to the disk, then ctrl-alt-delete.

Install Windows if you must

This is beyond the scope of this doc, but basically you use Windows fdisk to create its C: partition and any others you may need. Be sure to leave enough room for your future Linux distros. In particular, I am not sure whether extended partitions you create in Windows (for D:, E:, etc) prevent you from making extended partitions in Windows. This doc is really about multi-booting different Linux distros, so if you're installing anything but the simplest Windows with only a C: drive, you've got some research to do.

The methodologies for installing Windows from scratch are given in Building a Fresh New Win95 Machine and Building a Fresh New Win98 Machine.

Note that the majority of this document will assume you *DID NOT* install Windows on a partition.

Install your "best" distro, being sure to make a boot disk for it.

You need one Linux distro guaranteed bootable at all times. I call this the "best" distro. All distros are great, so you choose which distro you want to serve this purpose. The examples in this doc are Red Hat.

Install as usual, except that you must mount /dev/hda1 as /boot, and be sure you set it to boot off the MBR. Make absolutely sure you get a working boot diskette for your "best" distro setup. Test that boot disk. The other distros will most likely render your "best" distro unbootable. Although you can do some fancy footwork in one of the other distros to get it back, or you can wade in with a rescue diskette, by far the easiest way is with a boot floppy.

Install your other distros

Install your other distros, creating new partitions for each. I've had great luck letting all distros share a single swap partition. Of course you'd use multiple swap partitions if you were running VMware.

Boot back to your "best" distro.

Remember that boot floppy you made for your "best" distro? Use it. We'll assume your "best" distro is Red Hat, on hda2. Hda5 contains Caldera and hda6 Debian, with hda7 being swap. Hda1 of course is the /boot partition. If you look at your "best" distro's /etc/lilo.conf, it should look something like this:
 
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
image=/boot/vmlinuz-2.2.5-15
        label=linux
        root=/dev/hda2
        read-only  

Now simply change the label to label=rh to identify it among all the versions. Since the top one will default, you can still hit Enter on the boot prompt.

Now run the lilo command so you can boot back here without the boot disk:

# lilo
Then reboot. Hit the Tab key at the boot prompt, and it should list rh and nothing else. Hit Enter and you should be booted to Red Hat. Time to move on.

Mount the roots of the other distros

Assuming you installed Caldera's root on /dev/hda5 and Debian's root on /dev/hda6, and assuming you did nothing special with their /boot directories, you're ready. Do these two commands:
# mkdir /mnt/cald
# mkdir /mnt/deb
# mount/dev/hda5 /mnt/cald
# mount/dev/hda6 /mnt/deb

Copy image specifics from other disto lilo.confs to your "best" distro lilo.conf

Your /mnt/cald/etc/lilo.conf should look something like this:
 
#
# general section
#
boot = /dev/hda5
install = /boot/boot.b
message = /boot/message
prompt

# wait 5 seconds (50 10ths) for user to select the entry to load
timeout = 50

#
# default entry
#

image = /boot/vmlinuz-2.2.5-modular
        label = linux
        root = /dev/hda5
        vga = 274
        read-only
        append = "debug=2"
#
# additional entries
#

Copy just the portion from the image =  through the append = line, and paste them at the bottom of /etc/lilo.conf. This will be the portion to boot Caldera.

Similarly, copy the image portion of /mnt/deb/etc/lilo.conf to the bottom of /etc/lilo.conf. Save lilo.conf.

Modify "best" lilo.conf to reflect your present mounts and distro labels

With the Debian and Caldera mounts described previously, make the following changes to the Caldera portion of /etc/lilo.conf: You're probably wondering why the second change was necessary. After all, there's a root = /dev/hda5 line in the Caldera image code. Shouldn't LILO know to look for /boot/vmlinuz-2.2.5-modular there? No. Because often as not, the kernel is *not* on the same partition as the /boot.

Make similar changes to the Debian image of /etc/lilo.conf, except of course the label will be deb and the prepended mount will be /mnt/deb.

When you're done, your /etc/lilo.conf should be somewhat similar to this:
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
image=/boot/vmlinuz-2.2.5-15
        label=rh
        root=/dev/hda2
        read-only


image = /mnt/cald/boot/vmlinuz-2.2.5-modular
        label = cald
        root = /dev/hda5
        vga = 274
        read-only
        append = "debug=2"


image=/mnt/deb/vmlinuz
        label=deb
        root = /dev/hda6
        read-only                     

Run the lilo command with no arguments to update your MBR

Remember, none of this matters a hill of beans until you run LILO to transfer the info to the MBR. So, once again assuming you're still booted to your "best" distro and you still have the mounts in place for the other distros, simply do the lilo command:
# lilo
That's it. From now until you run LILO again, your lilo.conf is just documentation.

Reboot and test all distros.

# /sbin/shutdown -r now
When you get the boot prompt, press the Tab key. You should see a list of your distros:
rh   cald    deb
One at a time, try each one. Be sure you're booting the kernel you think you are. Running one distro's kernel with another distro's utilities and programs isn't a fun way to live, and you might not even know it. The default configuration of the Caldera kernel boots in GUI mode, so if you boot Caldera and it boots text mode, then after most of the boot completes it switches to GUI, you can be pretty sure you booted a Red Hat or Debian kernel into the Caldera partition.

Fix as necessary

If you don't get all three, or if some don't work, troubleshoot. Get into the "best" distro (by boot floppy if necessary), and make sure everything's mounted the way you think it is, everything points where you think it does, and rerun LILO. LILO should announce the addition of all three labels to the MBR. If not, that's a sure sign it's not finding something. Narrow it down.
 
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
image=/boot/vmlinuz-2.2.5-15
        label=rh
        root=/dev/hda2
        read-only


image = /mnt/cald/boot/vmlinuz-2.2.5-modular
        label = cald
        root = /dev/hda5
        vga = 274
        read-only
        append = "debug=2"


image=/mnt/deb/vmlinuz
        label=deb
        root = /dev/hda6
        read-only                     

Adding Windows to the Mix


Note: A Windows C: drive *must* be installed on a primary partition. If you believe you'll *ever* want Windows on a machine, allocate a 500MB or more  primary partition to be used later as the C: drive, before creating Linux drives other than hda1 /boot.  Use Dos's fdisk to create it. Then go about your Linux installs. Note that you may need to use dos fdisk can corrupt existing Linux partitions, a situation which may or may not be correctable with a rescue disk expedition.  Note that Win drives can be placed on virtual drives on the extended partition produced by Linux' fdisk. However, I cannot guarantee that any of the drives mentioned in this note will not "leak" over to the linux partitions and corrupt them.
Windows multi-boots can get nasty, especially if Windows is installed after the fact. I guarantee you will have some serious problems to deal with if you install Windows after the fact, or if you try to have a Windows D drive or E drive on the same drive as your Linux partitions.
If you install Windows after Linux, make sure you have a known good boot floppy for your "best" distro, as well as a rescue floppy, because the Windows install is going to overwrite your hand crafted MBR masterpiece, and maybe other Linux partitions. In tests, I was able to restore your Linux (but not eliminate a few bootup error messages) with a rescue floppy expedition. After the fact Win installs and multi-partition Win installs are beyond the scope of this document.

If you installed Windows before Linux, you'll see the following image inside your /etc/lilo.conf:
 
other=/dev/hda1
        label=dos
        table=/dev/hda

If you installed Windows after the fact, boot back into Linux with your boot floppy, or rescue yourself, or whatever (and of course you might have trashed your Linux setup for good), make sure your "best" distro is mounted root, and add the text above to the bottom of your /etc/lilo.conf. Make sure to change the /dev/hda1 in the other statement to whatever partition now holds Windows. Run Lilo and make sure it says it added all your distros and dos. If so, reboot, and you just might have an after the fact Windows multi boot.
 
 

Back to Troubleshooters.Com * Back to Linux Library