LILO with Etherboot
Ken Yap, <ken_yap AT users PERIOD sourceforge PERIOD net>
10 May 2002
This HOWTO explains how to install LILO on disks that do not have any Linux filesystems to boot DOS as well as Etherboot .(z)lilo images.
Motivation
LILO is perhaps the best known Linux boot loader and many people use it to single or multiple boot OSes?. What is less well known is that LILO can also boot from disks that do not have any Linux partitions at all. This follows from the design of LILO. The installer stores lists of disk blocks to read in and the boot time portion does not care what kind of partition the boot images are stored on. All that is needed is a way to run the installer on a non-Linux partition. Any filesystem supported by Linux can be handled, provided it can be mounted RW. This includes all the FAT based DOS and Windows filesystems.
What I describe below is not actually Etherboot specific. It will work just as well if you want to boot a Linux kernel from a DOS partition. It just so happens that Etherboot can build images that look like Linux kernels to the LILO installer. Therefore most of the cleverness is in getting a LILO installer to run on a non-Linux partition.
The steps
- Get hold of a rescue floppy like tomsbtrt (www.toms.net). Other rescue
floppies or CD's should work also. All you have to be able to do with the rescue disk is mount a DOS/Windows filesystem on the Linux filesystem.
The next 4 steps are done on a host Linux system.
- Get hold of a recent LILO distribution. I used lilo-21.7-5. Edit the
Makefile to generate a statically linked lilo executable by adding –static to the link command. Do a make. This will generate a lilo executable. You might want to run strip on this to reduce the size. Also generated will be various boot programs ending in .b.
- Create a working directory, say /tmp/lilo and under it mkdir boot/, sbin/
and etc/.
- Copy the .b files to /tmp/lilo/boot. cp -p /tmp/lilo/boot-menu.b /tmp/lilo
/boot.b. You can also substitute -text for -menu if you prefer a plain text prompt. Copy the lilo executable to /tmp/lilo/sbin. Create /tmp/lilo/etc/ lilo.con and add an entry for DOS. Add entries to /tmp/lilo/etc/lilo.con for the Etherboot images.
- Generate the Etherboot .zlilo or .lilo images you want and copy them to
/tmp/lilo/boot. Remember to alter the names to 8.3 standard as necessary.
- In /tmp/lilo, zip the contents to say /tmp/lilo.zip. Use a floppy or other
means to transfer this to the DOS system. To save you work, you can find a copy of this zip archive, minus the Etherboot images and the lilo.con modifications, here.
- Alternatively pack the archive with tar and gzip. This will allow you to
transfer this to the DOS system using the wget on the rescue floppy, see below.
- Unpack the archive in the root directory of the DOS system. If you are
using pkunzip, remember to use the option that preserves the paths. You should end up with three new top level directories: \boot, \sbin and \etc.
- Reboot the DOS system using the rescue floppy. Mount the DOS filesystem,
say on /mnt.
- Make a symlink from /mnt/boot to /boot. You can't use the -r /mnt option
of lilo because it will chroot to /mnt and look for /mnt/dev/hda, and of course those device files don't exist on a DOS FS.
- Run /mnt/sbin/lilo -v -C /mnt/etc/lilo.con This will write LILO into the
master boot sector.
- Umount /mnt and reboot. Keep the rescue floppy around for future
modifications to \etc\lilo.con.
- If you made a .tar.gz package instead of a .zip package, then you can
streamline all of the above with a couple of commands if you have a web server handy and you can put a shell script and the .tar.gz package there.
Once you have booted tomsrtbt, issue a wget for the install shell script, something like this:
wget http://172.16.2.25/thin/install.sh
install.sh contains:
#!/bin/sh mount -t msdos /dev/hda1 /mnt (cd /mnt; wget -O - http://172.16.2.25/thin/lilo2175.tar.gz | gunzip | tar xf - 2>/dev/null) rm -f /boot ln -s /mnt/boot /boot /mnt/sbin/lilo -v -C /mnt/etc/lilo.con umount /mnt
Run it with:
sh install.sh
- Advanced: If you have several types of network cards on your network, you
could provide different install scripts for them which would fetch different images. Or you could parameterise install.sh. Of if you are really cunning, you could try to extract the network card identity out of a lsmod, as tomsrtbt autoprobes for several common NICs?.
- LILO should take control on boot up and there should be entries for DOS
and each Etherboot image. You can even have fancy splash graphics, this is a LILO enhancement in some distributions like SuSE.
Notes
- The reason for making LILO afresh instead of using the one on the rescue
floppy is that the lilo executable must match the boot programs, otherwise you get mysterious errors like Map segment is too big. For example the LILO in tomsbtrt is version 20.
- Since LILO relies on the boot images staying at their block locations on
the disk, if you ever defrag the partition containing the boot/ files, and the files get moved as a result, then LILO will fail. So it would be a good idea to mark those files as unmovable (system and RO I think). If you accidentally move the images, then you have to run the LILO install step again.