Supermin appliance – now in febootstrap

Q: Can you fit a bootable Fedora distribution into 100 kilobytes?
A: You bet!*
* by cheating … read on.

Take an ordinary Fedora appliance as made by febootstrap or appliance-creator. The appliance image is big because it contains copies of programs (/bin/bash) and libraries (/lib/libc.so), the kernel and kernel modules. It needs to, to make it self-contained.

But a technique we’ve been using for a few months in libguestfs is to say: we’re booting this appliance on a Fedora host. Let’s strip out all those programs and libraries from the appliance, and we’ll add them back from the host just before we launch it.

I called such appliances “supermin appliances”, and now I’ve ported the functionality from libguestfs into febootstrap so everyone can use it.

A supermin appliance is really small:

-rw-rw-r-- 1 rjones rjones 14K 2009-10-22 12:43 hostfiles.txt
-rw-rw-r-- 1 rjones rjones 87K 2009-10-22 12:43 supermin.img

yet it’s fully bootable, given the right sort of host:

It’s really easy to use the new febootstrap to make your own super-small supermin appliances.

We’ll start with this small shell script to make a supermin appliance:

#!/bin/sh -
distro=rawhide
febootstrap -i bash -i coreutils $distro fedora
febootstrap-minimize fedora
cat > init <<EOF
#!/bin/sh
echo Starting /init script ...
PATH=/sbin:/usr/sbin:$PATH
touch /etc/fstab
mount -t proc /proc /proc
mount -t sysfs /sys /sys
exec bash -i
EOF
febootstrap-install fedora init /init 0755 root.root
rm init
# Create the supermin appliance.
febootstrap-to-supermin fedora supermin.img hostfiles.txt
# Create the ordinary appliance just for comparison.
febootstrap-to-initramfs fedora > ordinary.img

You will need to use febootstrap >= 2.5, and set the distro variable so it exactly matches your base Fedora system (eg. set distro=fedora-11).

The script below can be used to boot the appliance, and it’s what I used to get the screenshot above.

#!/bin/sh -
time febootstrap-supermin-helper \
    supermin.img hostfiles.txt kernel initrd
qemu-system-x86_64 -m 1024 -kernel kernel -initrd initrd

4 Comments

Filed under Uncategorized

4 responses to “Supermin appliance – now in febootstrap

  1. Pingback: Creating ext2 filesystems from scratch « Richard WM Jones

  2. Dinooz

    Great work, I have a few questions….
    a) How can we update some packages, will yum work ?
    b) Does it have gcc in case we need to install some extra packages or they need to be compiled in the host and then copied to the Supermin appliance ?
    c) Can we use this supermin.img to make it bootable from USB ?

    Keep doing the great job !!!.

    • rich

      For an update on this post, see:

      An explanation of supermin appliances

      a) In theory, yes. However if you “minimize” the appliance then no, because minimizing usually involves deleting the rpm metadata, yum cache etc. Generally we treat supermin appliances as completely throwaway, so this is not a problem.

      b) See the febootstrap man page in the link above.

      c) Not tried it, but in general supermin is only applicable to virtual machines, not to real machines.

  3. Pingback: a-fedora-appliance updated for supermin 5 | Richard WM Jones

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.