PicoDebian

PicoDebian is a thinned-down version of the Debian Sarge GNU/Linux distribution. It is inspired by the Pebble distribution and is small enough to boot off a 32MB CompactFlash card. It uses the standard Debian packaging tools for simplicity.

See the SourceForge Project Page for downloads, etc… There is now also a PicoDebian wiki that should turn into the main resource for PicoDebian at some point.

A completely new version is on the books and if you have any suggestions please check out the wiki (above) and let me know your thoughts.

Why did I do it?

My main router / firewall, Piccolo, ran Debian Sarge from a 2.5″ laptop hard disk. This was bad for several reasons:

  1. Laptop hard drives are not designed for 24/7 operation. I know this for a fact, since my PowerBook’s hard drive died not too long ago. I use my laptop a lot.
  2. It’s a rather inefficient use of space. The hard drive is 30GB, and the installed OS on it only uses about 200MB. With my compacted read-only version of Debian, the root FS takes 24MB compressed, or about 68M uncompressed.
  3. It’s power hungry and hot. Maybe not compared to desktop or server class machines, but this is a rather tiny machine. The hard drive uses a substantial amount of power and does run quite hot.
  4. I can’t just pull the plug on the thing. Everyone knows that pulling the plug out of a running computer is a bad idea. That’s only because the file systems are read / write. This will be entirely read only, so you can just yank it to reset it.

There is already a Debian-based distribution for small systems called Pebble, but it’s based on Debian Woody (which is old) and although is read-only it keeps everything it needs around. That means it takes much more space than it need to: my 24MB image includes all sorts of extras like udev, nvi, hotplug, etc… Also, Woody is far too old for my wishes.

Since this is a stock Debian install with a customized kernel, it will run on just about anything. This was, however, just built for use on a Soekris net4801.

How does it work?

I basically stole the idea from Pebble and improved on it a little. It’s a nice simple system and didn’t take much tweaking to get working. Basically, everything is on a SquashFS compressed root filesystem. The few things that need to be writable are copied from /ro to /rw, which is a tmpfs (RAM disk), and symlinks are made from around the filesystem to the appropriate locations in the RAM filesystem. Only about 100K of data is copied over, and that grows to around 250K when fully booted. Logging is taken care of by sending messages to a log host, one of my other machines, so that I don’t need to worry about logs taking up all the RAM.

The /boot filesystem is ext2 so that GRUB can read from it. This is not meant to be mounted read/write at all, but can be for example when a kernel is upgraded. Since my flash disk is 512MB, I can keep multiple backup copies of both the boot and root partitions around in case things go really wrong.

I have a script that builds the root filesystem image for me, which is basically a short wrapper around mksquashfs. It uses an exclusion list to ignore the rather big but utterly useless (for a read-only embedded system) files and directories like the APT cache, package lists, documentation, and extra locales (about 100MB). So, from a 168MB directory, I get a 68MB root filesystem and a 24MB compressed SquashFS image ready for flashing.

Development of this project is taking place on SourceForge.net. Visit the project page for more information. Also check out the wiki!

What’s in the 24MB?
My 24MB root filesystem contains a full Debian Sarge (3.1) base system, and the following additions:

  • ISC BIND 9. Mostly used as a caching DNS server for my network, also serves a few zones only used on my home network.
  • ISC DHCP. Gives out IP addresses for all the machines on my network.
  • monit. Makes sure everything on the machine is running correctly, and restarts crashed services.
  • NTP. The master time server on my network. All other machines sync to Piccolo.
  • OpenSSH. So I can get into it to administer it. There is also the serial console when things go really wrong.
  • OpenVPN. For access behind the firewall from other places on the ‘net. Works a treat too.
  • PERL 5.8. Probably the biggest thing on the box: necessary for some of the other things like NTP and Snort.
  • Shorewall. Sometimes called the Shoreline Firewall. Great lump of code, but it does make the boot process take ages!
  • Snort. Logs and gives me reports every day about malicious traffic. Logs to a MySQL database on another machine (yes, there is a mysql client on Piccolo).
  • Watchdog. Should Piccolo crash, the watchdog timer should reboot it automatically.
  • WonderShaper. Best thing since sliced bread: “The Ultimate Traffic Conditioner: Low Latency, Fast Up & Downloads”
  • My LCD Daemon. A little piece of code I wrote to drive the LCD panel I installed in Piccolo.

Other things include bzip2, deborphan, hotplug, less, nvi, ssmtp, sudo, udev, and wget. Impressed yet? Also, my 8MB boot filesystem only contains about 1.8MB of GRUB and kernel code.

Note: This project has nothing to do with PicoLinux (which is Linux for handhelds), and is not affiliated with the Debian project in any way. It’s got Pico in the name because it runs on Piccolo, and Debian is there because it’s based on Debian.