The general idea is to compute a kernel and put it on a floppy. Then prepare a complete file system, compress an image of it, and put it onto the same floppy. Finally tell the kernel on the floppy where to find this compressed image and also tell it to load it into a ram-disk. The kernel compilation goes as usual, just create a kernel with everything that you need already in it, no modules. In particular it should have support for ftape, ram-disks (including initialization at boot), aout and elf binaries. Compile and copy to the floppy as in
dd if=/usr/src/linux/arch/i386/boot/zImage of=/dev/fd0 bs=1024
Make note of the number of blocks written, I'll assume here that it is less than 500.
Then get hold of a root disk (for example the slackware root disk color) and copy it on a file system of the desired size (4MB).
insmod rd # load the ramdisk driver if it's a module zcat color.gz > /dev/ram1 mount -t ext2 /dev/ram1 /mnt1 # now /mnt1 has a complete root system # now prepare the second ram disk, first write zeros as the compress well dd if=/dev/zero of=/dev/ram2 bs=1024 count=4096 # and create the file system, 0% reserved for the super user mke2fs -vm0 /dev/ram2 4096 # now mount it and copy the root system into it mount -t ext2 /dev/ram2 /mnt2 cd /mnt1 find . -print | cpio -pdv /mnt2
At this stage we have a complete file system on /mnt2. However, it might not have all the binaries you want it to have. Note, all binaries you want to install must be aout binaries, as this is the only libc libraries that's going to be on the floppy. Let's deal with the libraries now.
cd \lib
cp ld.so /mnt2/lib
cp ld-linux.so.1.9.5 /mnt2/lib # or whatever you have that
# supports both elf and aout
cp libc.so.4.7.5 /mnt2/lib # the last aout libc
cd /mnt2/lib
rm lclite.4.6.27
ln -sf libc.4.7.5 libc.so.4
ln -s /mnt/lib/libc.so.5 # so we can use elf binaries after
# we mount the hard drive under /mnt
ln -s /mnt/lib/libc.so.6
ln -s /mnt/lib/libm.so.4
ln -s /mnt/lib/libm.so.5
ln -s /mnt/lib/libm.so.6
Now also copy all the binaries into /mnt2/ that you want on the rescue floppy. However, they must be aout versions! You most likely will have to compile them and cannot just use the ones from your hard drive. I installed ps, free, mt, vi, cpio, df, e2fsck, hostname, lilo, gpm, and as the upgrade of the C library caused problems with logging in also login.
Here are a few hints on how to recompile those binaries.
CC="gcc -V2.7.2 -bi486-linuxaout -s" ./configure make cpio make mt
make CC="gcc -V2.7.2 -bi486-linuxaout -s" ps make CC="gcc -V2.7.2 -bi486-linuxaout -s" free
mkdir build cd build CC="gcc -V2.7.2 -bi486-linuxaout -s" ../configure make e2fsck
make CC="gcc -V2.7.2 -bi486-linuxaout -s" free
CC= gcc -V2.7.2 -bi486-linuxaout -s
then run the commands
cd login-utils make login cd ../misc-utils make hostname
Finally, put all of them onto the floppy. Then edit the file /mnt2/etc/rc so that you get the message you desire when you log in, also set the host name. The login message is in issue, so edit that, too. If you moved files from etc sbin you might also have to edit inittab. Also edit fstab to have the correct entries.
/dev/ram / ext2 defaults 1 1 /proc /proc proc defaults 0 0 /dev/hdc /cdrom iso9660 ro,suid,dev,exec,auto,async 1 1 /dev/hdd /cdrom iso9660 ro,suid,dev,exec,auto,async 1 1
Get the location of the darn utmp file correct, it should be in somewhere in /etc, /var/adm, or /var/run, and linked from the other two places. The wtmp file needs to only appear in /etc and /var/adm.
After everything is set up to your liking, unmount the ram-disk, compress an image of it, and write it to the floppy at the appropriate place.
cd umount /mnt2 dd if=/dev/ram2 bs=1024 count=4096 | gzip -9c >/root/tmp/rd.gz dd if=/root/tmp/rd.gz of=dev/fd0 bs=1024 seek=500
Make sure that it fit onto the floppy! Now we have to tell the kernel on the floppy where to find the ram disk, and that it should load it at boot time.
rdev /dev/fd0 /dev/fd0 # tell the kernel on /dev/fd0 that
# the kernel is on /dev/fd0
rdev -r /dev/fd0 16884 # this tells the kernel to load the
# ram-disk (set bit 14) located at block 500:
# 16884=2^14+500
rdev -R /dev/fd0 # tell the kernel to mount the root
# system read/write enabled
This can also be done before you write the kernel to the floppy, the commands are then:
rdev zImage /dev/fd0 rdev -r zImage 16884 rdev -R zImage
Now reboot off the floppy. You should get some error message relating to the library versions the dynamic linker is using. Fix this as follows.
mount -t ext2 /dev/hda2 /mnt # assuming your hard drive linux
# partition is hda2
ldconfig -v
Now repeat the whole procedure of putting the image onto a ram disk, put that file ld.so.cache into it, and finish off as before.
zcat /mnt/root/tmp/rd.gz >/dev/ram2 mount -t ext2 /dev/ram2 /mnt2 cp /etc/ld.so.cache /mnt2/etc/ld.so.cache umount /mnt2 dd if=/dev/ram2 bs=1024 count=4096 | gzip -9c >/mnt/root/tmp/rd.gz dd if=/mnt/root/tmp/rd.gz of=dev/fd0 bs=1024 seek=500
Reboot and check that it works. In particular check mt and ftape if you want to use this disk to recover from disaster.