B. Dushaw (dushaw@apl.washington.edu)
December 2000; last revised 27 August 2001

Comments on Making a Linux Rescue/Boot CD [without using a floppy drive].

WARNING: This page is now so old as to be deprecated. Try e.g., one of the SuSE linux installation CD's as a rescue disk.

I needed to make a rescue CD for linux because: (1) My ACER 600TER notebook does not have a floppy drive, so if I needed to fix the system with a rescue floppy, I was S.O.L., (2) The RedHat CD "rescue" mode never seems to work for me, and (3) floppies are sooooooo slooooooowwwww. [You can download a copy of the ISO image of my rescueCD (14 MB gzip'd), if you like. Gunzip it and burn the image directly onto a CD. It is a generic 2.2.19-pre9 kernel, with the system based on RedHat 6.2, but it won't work if you have a pure SCSI system because SCSI is supported by modules and you will need to mount the CD to get access to the modules. This image was last modified (August 2001) to be more up to date and user friendly; it uses the lilo boot loader with apparently won't work for some bioses. It does have support for the PROMISE ULTRA33/66/100 cards, and it now includes a networking script to get networking going (if one of the kernel modules on the CD happens to work for your ethernet card). I've also recently discovered the superrescue CD at the kernel.org site - apparently a rescue disk with more features than you can shake a stick at, although I have not tried it.]

See also Timo's Rescue CD site. Most of my revisions were derived from the information contained there. However, Timo tells me that the procedure outlined below will not work for some systems with "buggy bioses", he gives the rumoured example of "Newer IBM Thinkpads". See Timo's precise words and suggestions for a better way to make rescue CD's in his e-mail. Just when you think you have it all figured out, someone comes along with a buggy bios....grrrrrr :)

Bear in mind that when booting from a CDROM, you may have to enter the bios (hit <del> at bootup, probably) to have the computer search for a bootable image on the CDROM. Most bioses are set up to first look at the floppy drive, then the hard drive, and then (maybe) the CDROM. You need to change this ordering to have the computer look at the CDROM first (or at least after the floppy).

I followed the Bootdisk-HOWTO fairly carefully, but the the description of the use of LILO there will not work for CD rescue disks. See also the YARD package . Here, then, are my "corrections" to the Bootdisk-HOWTO (BDH, hereinafter), bearing in mind that I am no expert.

The BDH has an important section on PAM (4.4). One correction is that with the use of the /etc/pam.conf file, the directory /etc/pam.d should not exist. If it does exist, one will not be able to log in (at least that was my experience - a login prompt for which all logins fail.)

Section 10.3 has the telling, yet cryptic, statement: "One Caveat--Your boot floopy must load any initial ramdisk via LILO, not the kernel ramdisk driver! .... ". Most of the discussion below is how to do this, because the BDH, as well as the LILO documentation, come up a little short in their descriptions. See the file /usr/src/linux/Documentation/initrd.txt. The main issue is that the approach to making a CDROM disk is quite different than for a floppy. In the approach of the BDH, the kernel boots up and then the kernel floppy driver reads in the rescue disk image. With a CD, the kernel finds no floppy, of course, and so it crashes with complaints. The CD needs to have the rescue disk image already loaded into memory by the boot loader BEFORE the kernel starts up, so that all the kernel has to do is transfer the rescue image from one part of memory to /dev/ram0.

Cookbook style:

  1. I made a boot/root disk. You do not need to actually have access to an actual floppy drive for this, and the El Torito standard actually allows the "disk" to be 2.88 MB in size, rather than 1.44 MB which is very nice.

    To mimic a 2.88MB "floppy" on your system execute:

    "dd if=/dev/zero of=/tmp/boot288.img bs=512 count=5760" followed by

    "mke2fs -i 8192 -m 0 /tmp/boot288.img". Answer 'y' to the question. [NB: You are formatting the ENTIRE "floppy", unlike the instructions in the BDH.]

    You can then mount the "floppy" by "mount -o loop /tmp/boot288.img /mnt/floppy".

    Once you have the contents of this floppy correctly built, and have executed LILO properly, you are set and can follow section 10 of the BDH.

  2. Populating the rescue filesystem (section 4.3) [Not used for a simple boot CD]. It proved quite difficult to put everything one needs onto a miserable floppy 1.44MB floppy, but having 2.88MB proved to be generous (the main problem then being the available 4MB of RAM space.) My strategy was to put most of the things one would need (tar, fsck, kernel modules, etc.) onto the CDROM that would be mounted after the minimal system was booted up. After bootup and mounting the CD, one can copy all the tools, libraries, modules, etc. one would ever want from the CD onto the rescue root filesystem. I therefore pared my root filesystem for the floppy down to the bare minimum, making sure that I had all the things one needed to log in and mount the CD.

  3. Section 6.1 - the configuration file for LILO. Rather than using "root = /dev/fd0", use "root=/dev/ram0". Also add the line "initrd=rootfs.gz". Various other parameters are used to fool lilo into thinking that the loop device (which is what you are using) is a floppy drive. My bdlilo.conf file is:

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    boot = /dev/loop0

    disk = /dev/loop0

    bios = 0x00

    sectors = 36

    heads = 2

    cylinders=80

    install = /mnt/floppy/boot/boot.b

    map = /mnt/floppy/boot/map

    read-write

    backup = /dev/null

    compact

    image = vmlinuz

    label = Bootdisk

    root = /dev/ram0

    append = "ramdisk_size = 4096" [probably not necessary; if you want this to be different (i.e. larger) you can set the number to be, e.g. 8192, or some number less than the memory you have on your computer.]

    initrd = rootfs.gz

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    N.B. If all you want is a boot CD (e.g., to boot up a new kernel for testing) then: (1) dispense with the rescue filesystem, the "initrd=rootfs.gz" line, and the "ramdisk=4096" line, (2) set "root=/dev/hda5" (or whatever your root device is) and (3) change "read-write" to "read-only" in the lilo configuration file. You will only need the /mnt/floppy/boot directory, the /boot/boot.b file copied to that directory, the kernel image, and the lilo.config file on the floppy.

  1. With the LILO configuration file set up as above, you can execute "lilo -v -C /mnt/floppy/bdlilo.conf " as given in the BDH (if your floppy was mounted on /mnt/floppy). NOTE that if you did not mount the floppy by "mount /dev/fd0 /mnt/floppy", but did "mount /mnt/floppy" instead (relying on your /etc/fstab), lilo will not execute properly. ("permission denied" happens...I hate it when that happens...) N.B. The BDH has one execute lilo with the option "-r /mnt/floppy", but this proved not to work here (?); I put in the complete filename: "/mnt/floppy/boot/boot.b" in the bdlilo.conf file. It also appears that the lilo information is not retained in the file /tmp/boot288.img after a reboot?? You can't run lilo too often... Be careful not have lilo write its information to your computer's MBR rather than the "floppy".

  2. At startup, LILO will load rootfs.gz into memory at /dev/initrd. It will then transfer those contents and uncompress them into /dev/ram0. If the root device is set to /dev/ram0 (hence, "root=/dev/ram0" in the LILO config file), then bootup will procede normally.

  3. The ramdisk word (section 6.3 of BDH) of the kernel image should be set to zero, i.e. do nothing to the kernel image.

  4. Assuming you have made and compressed your root filesystem (see Section 4 of the BDH), you will now copy this file (e.g., rootfs.gz) onto the floppy filesystem "cp rootfs.gz /mnt/floppy". [This is DIFFERENT than the procedure of the BDH, where you do a raw copy of this file to /dev/fd0, so that it starts immediately after the small filesystem you made.] Done correctly, "ls /mnt/floppy" will list "bdlilo.conf, vmlinuz, dev, boot, and rootfs.gz".

  5. This boot disk should be ready to go. Unmount it: "umount /mnt/flopppy". [If you made an actual floppy: Test it by booting off of it, then "dd if=/dev/fd0 of=rescue.img bs=10k count=144" will make an image of the rescue floppy for putting on the CD. (The "bs=10k" makes the copy go a little faster.)] If you made the loop device filesystem above, then the "floppy" image is merely the file /tmp/boot288.img.

  6. In a separate directory on the PC, "/home/yourname/rescueCD" say, make directories boot, usr, sbin, lib, lib/modules, lib/modules/2.2.18, and anything else that you think you might need when your system is undergoing cardiac surgery. Into these directories, copy the contents of your systems /usr, /sbin, /lib, /etc, including useful tools like /usr/bin/which and /usr/bin/ldd (the latter is used to test the library dependencies of executables). Into the boot directory, you can put the floppy image "boot288.img". When the directory "rescueCD" has everything you think you might need (don't hold back, you get 650 MB of space....), you can now use XCDROAST to make an ISO image of that directory, setting the El Torito boot image to "boot/boot288.img" and boot.catalog to "boot/boot.catalog" (N.B. No initial slash. boot.catalog is merely a placeholder, a name that is required. You don't really have to make a boot.catalog.); and burn the ISO image onto a CD. Be sure to test the CD ahead of time; the floppy image may work from the floppy and fail to work from the CD if the ramdisk was not loaded properly.

    If all you want is a boot CD, e.g. to test a new kernel, then the filesystem in "/home/yourname/bootCD", say, will have only the boot288.img file in it. Use xcdroast as above, with the boot image "boot288.img" and boot.catalog "boot.catalog"...you get the idea.

    Happy rescue booting!!

    Finally, I note that it should now be obvious how one would go about making a CD that would contain an entire linux system on the CD. This installation could be set up such that after linux boots off the CD, then X windows, for example, is made available from the mounted CD. The whole system runs off of memory and ramdisks; no hard disk needed (but probably at least 128 MB of RAM). You would need some way of saving your work, however, or perhaps the PC is set up just to run a set of specific tasks. You could make a CD of your favorite linux arrangement, and so carry your linux around for ready access on any PC you happened to need it on. You could also go around clandestinely booting up linux/X windows from a CD on all the computers at the local PC store (no harm, no foul), but you did not hear this idea from me...