O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  



Fast LILO boot floppy
Sometimes you want to leave the hard drive's boot setup alone, But booting from floppy is too slow or your bootimages (bzImage + initrd) don't fit on the floppy. Make a Linux Loader floppy that uses bootimages on the hard drive.

Contributed by:
clsgis
[06/05/05 | Discuss (0) | Link to this hack]

Sometimes you want to leave the hard drive's boot setup alone, Whatever Linux installer you're using only has options to "make the hard drive bootable" or "make boot floppies" and neither one is really what you want. Perhaps you're developing a network install setup or preinstalling a drive for somebody else's computer. Maybe you're just learning about kernel 2.6, and you discovered you can't just copy bzImage to the raw floppy device any more. Maybe you've got a Compaq Armada and sombody blew away its hard drive-resident boot utilities. You just want a faster boot floppy for that drive, or you want one boot floppy instead of a kernel disk and an initrd disk.

For example, I'm preinstalling Debian on a drive which will be the new /dev/hdb in my friend's PC. Right now it's /dev/hdb in my test PC. My friend doesn't want to touch MSFT's MBR just yet. None of Debian's kernels was just right for my friend's old Dell, so I built a new bootimage file /usr/src/linux-2.6.11.11/ arch/i386/boot/bzImage and he's gonna use a boot floppy for a while.

I'll use the DOS file system for its low space overhead. I'll prepare the diskette by filling it with zeroes so its image will compress well, and testing it. I'll put a backup copy of the bootimage on the floppy, but we probably won't need it. You may have to be root to do this.

  ps axw | egrep '(amd|mount)'   # look for interfering daemons
  killall /usr/sbin/automount   # and kill them!
  umount /dev/fd0
  dd bs=1k < count=1440 /dev/zero > /dev/fd0
  floppycontrol -f
  dd bs=1k count=1440 < /dev/zero | \
    cmp - /dev/fd0  && \
    echo the diskette has no defects

  mkdosfs /dev/fd0
  mkdir /fd
  mount -t msdos /dev/fd0 /fd
  cp /boot/boot-menu.b /fd/boot.b
  cp /usr/src/linux-2.6.11.11/arch/i386/boot/bzImage /fd  || \
  echo oops the copy failed
  # use whatever editor you like
  vi /fd/conf /fd/msg

This is /fd/conf

  compact
  boot=/dev/fd0
  root=/dev/hdb2
  install=menu
  map=/fd/mapfile
  menu-title="Dorothy's boot floppy"
  message=/fd/msg
  prompt
  timeout=500
  vga=normal
  image=/usr/src/linux-2.6.11.11/arch/i386/boot/bzImage
    label=hdlinux
    read-only
  image=/fd/bzimage
    label=fdlinux
    read-only
  other=/dev/hda
    label=msft
  other=/dev/hdb
    label=hdb

Here's the install command. I'll use the boot loader boot-menu.b from where Debian put it. You might find it someplace else on your system.

  lilo -i /boot/boot-menu.b -C /fd/fd0
  umount /fd

The /fd/msg file is any text you want between the menu and the boot prompt.

Here's a command to store a compressed image of this floppy in /boot.

  bzip2 < /dev/fd0 > /boot/bootfloppy.bz2
and this command makes a new diskette.
  bzip2 -dc /boot/bootfloppy.bz2 \
    > /dev/fd0  && floppycontrol -f  && \
    bzip2 -dc /boot/bootfloppy.bz2 | \
    cmp - /dev/fd0  && \
    echo the copy is good

Floppies go bad, so you should make a new one every few months. At boot time, the Linux Loader LILO reads the mapfile from this floppy, and the bootimage from hard drive. The other menu choices boot the backup bootimage, or the Master Boot Records from either hard drive. Maybe you set up the GNU Grand Unified Boot Loader on the second drive, but your old BIOS won't load it from there. This will launch GRUB, quickly.

The Linux Loader is still evolving. You might need to upgrade to the current version. You might have the obsolete LaTeX documentation. (For example, the function of the install= directive has changed since that was written.) You might find newer documentation packaged with Lilo's source code.

See also:


  • man lilo
  • man lilo.conf
  • man mount


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.