Creating a Zip bootdisk which runs Linux in a ramdisk
This document tries to describe what needs to be done to create a pair
of disks (floppy and zip disk) to boot Linux from and have it run
completely in a ramdisk.
This approach is similar to other minilinuxes, which boot from a
single floppy disk, but some of thouse systems keep (a part of) the
floppy mounted. The advantage of this setup is that you can boot your
system and then take out the disks and it will continue to run (this
might be useful for e.g. installing a cluster). You could of course
also do this with e.g. muLinux or some other "one floppy Linux
system", but a Zip disk allows you to have a much more comfortable
system. The disadvantage is that you need some amount of RAM in your
machine, as you need a ramdisk for your whole system (80 MB in our
case) and should still have some spare RAM for your programs to run.
This description is by no means complete or perfect, but I hope it
will help someone with the same or similar goals. The ressources I
found helpful during my installation were:
Maybe this document is too much focused on our own system (a cluster
of 400 HMz Pentium II machines with 128 or 256 MB of RAM and SCSI
disks, see the CoPs
project). Hopefully it's still useful... You should already have
some experience with Linux as I will not explain everything from the
I will try to write down what had to be done to make the boot disks
work. Much of the following should be done as root, so be careful.
A boot floppy disk
Take a fresh floppy disk and create an ext2 filesystem on it
("mke2fs /dev/fd0"). Put your kernel image (bzImage) and the
boot-sector (usually /boot/boot.b) on it using the
cp command. Note that your kernel must have ramdisk as well
as initrd support. If your Zip drive is on a SCSI bus, your kernel
also needs SCSI support (I don't know what to do with other Zip
Then, create an empty file of approx. 1.4 MB in size ("dd
if=/dev/zero of=floppyroot.img bs=1024 count=1400"). This file
must reside on a local harddisk, NFS doesn't work. Create an ext2
filesystem in this file ("mke2fs -m 0 floppyroot.img", the
"-m 0" tells mke2fs not to put any space aside for the
Mount the file using the loop interface (your kernel must support
this... "mount -o loop /tmp/floppyroot.img /mnt") and put a
very minimal system on it (in /mnt). I took most of the very
small files from the muLinux distribution (if you unpack the sources
for the muLinux distribution, you will find many things in the
tree subdirectory. It's quite useful as these programs have
been made as small as possible). What you need is at least:
You also need a file "linuxrc" in the root of your floppy
image. The file has the following contents (substitute your own Zip device/partition for the "XX", e.g. "sdb1"):
- In /bin:
- (maybe) sleep
- In /etc
- termcap (maybe?)
- In /lib:
- The mount points for /mnt, /zip and /proc
- Maybe /tmp
- In /usr/lib:
- Maybe /var/tmp
[ -x /bin/sleep ] && sleep 2
echo Preparing to setup ramdisk.
mount -o remount,rw / 2>/dev/null
echo Mounting proc...
mount -t proc none /proc
echo Mounting zip readonly...
mount -o ro /dev/sdXX /zip
echo -n Copying new root to ramdisk... please wait...
gunzip -c /zip/minisys.dd.gz > /dev/ram1
echo -n Unmounting zip...
echo Changing to new root.
echo 257 >/proc/sys/kernel/real-root-dev
echo -n Unmounting proc...
echo Continuing normal boot procedure from ramdisk.
Make sure that the script has execute permission. Unmount the
floppyroot.img ("umount /mnt") and compress it ("gzip
Your Linux system for the ramdisk
Create a partition somewhere on your harddisk of about 80 MB in size
(you can again use the "-m" switch for the "mke2fs"
filesystem to save some space). You could probably also use the loop
interface again, but then you can't test your installation. Install
your complete Linux system in that partition. I did so by installing
nothing but the minimal requirements from the SuSE CD (we usually use
SuSE Linux) and some small stuff
required for system and network diagnostics as well as some tools for
installations (you should know yourself what you need on your
system...). After making sure that your system works, change the
/ entry in /etc/fstab to /dev/ram1, because
that's where your root filesystem will be after the system is booted
from the ramdisk.
When your partition is ready, unmount it and create a compressed image
("dd if=/dev/hdx | gzip -c > minisys.dd.gz"). This may take a while.
The Zip disk
Create a single partition on an empty Zip disk, create an ext2
filesystem in the partition and copy the file with your Linux system
to it (minisys.dd.gz in this example).
The LILO config file
To install a bootable floppy disk, we need lilo. You probably don't
want to change your real lilo file (it's not required here
anyway). Create a file lilo.zip.conf with a content similar to the
# Test lilo.zip.conf for ramdisk boot zip with floppy.
append="INFO=1440 load_ramdisk=1 prompt_ramdisk=1 ramdisk_size=84000 ramdisk_start=652"
Check the file and make sure that all the devices are correct for your
setup. Also check:
- The uncompressed image of your Linux system must fit into the
ramdisk (to check the uncompressed size of your compressed Linux
system image: "gunzip -c minisys.dd.gz | wc -c"). Make sure
that you reserve enough kB in the above "ramdisk_size" parameter.
- The above parameter "ramdisk_start" (again in kB) must be larger
than your kernel image (bzImage).
Putting everything together
To finish everything, mount your floppy disk under
/floppy and your Zip disk under /zip (or wherever
you want, but don't forget to change the above lilo.zip.conf). Then,
try "lilo -C lilo.zip.conf".
Now, if you boot from the floppy, the following should happen:
I hope it works for you too!
- The LILO prompt appears. After that, the kernel is loaded from the floppy disk.
- The kernel is startet and initialises itself.
- The kernel loads the first, very small root filesystem (floppyroot.img.gz) to the ramdisk, uncompresses it and mounts it as root filesystem.
- The kernel finds the /linuxrc script and executes it.
- The script then loads the Linux system image (minisys.dd.gz) from the zip drive, uncompresses it on the fly and writes it to the second ramdisk.
- The script changes the kernels root filesystem to the second ramdisk.
- The system boots in its normal way from the ramdisk.
ICS [Laboratory for
[Dept. of Computer Science], ETHZ
[Swiss Institute of Technology], Patagonia Cluster Project.
Maintained by Felix Rauch.
Last changed: 10-Dec-1999