  LILO with Etherboot
  Ken Yap, <kenUNDERSCOREyap 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 .(lz)lilo images.

  11..  MMoottiivvaattiioonn


  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.


  22..  TThhee sstteeppss



  1. Get hold of a rescue floppy like tomsbtrt (www.toms.net). Other
     rescue floppies or CDs 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.


  2. 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.

  3. Create a working directory, say /tmp/lilo and under it mkdir boot/,
     sbin/ and etc/.

  4. 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.

  5. Generate the Etherboot .lzlilo or .lilo images you want and copy
     them to /tmp/lilo/boot.  Remember to alter the names to 8.3
     standard as necessary.


  6. 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
     <http://etherboot.sourceforge.net/lilo2175.zip>.

  7. 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.

  8. 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.

  9. Reboot the DOS system using the rescue floppy. Mount the DOS
     filesystem, say on /mnt.

  10.
     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.

  11.
     Run /mnt/sbin/lilo -v -C /mnt/etc/lilo.con This will write LILO
     into the master boot sector.

  12.
     Umount /mnt and reboot. Keep the rescue floppy around for future
     modifications to \etc\lilo.con.

  13.
     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
  ______________________________________________________________________



  14.
     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.

  15.
     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.


  33..  NNootteess



  +o  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.

  +o  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.






























