Embedding Debian has various problems, some of which are solved in different ways by stuff like Emdebian, flashybrid, and the ADS root builder. This is an attempt at one solution that should work for most use cases, while also being a lot easier to set up, and more flexible than any of these.

Joey posted some example use cases in his blog: <http://kitenet.net/~joey/blog/entry/embedding_debian.html>

Like flashybrid, it assumes a system that has some limited flash memory, and a large removable disk. Like the ADS root builder, it tries to only put the minimum files needed to run the embedded system on flash, and it determines this based on the system being exersised to catch all needed files.

The idea is to have a daemon that adds files to a jffs2 (or other filesystem in flash) on the fly as they are accessed from the disk.

To start, the system would boot as follows:

rootsync would do the following:

So a system booted this way could start with an empty jffs2, and as it boots, the jffs2 would be populated with the files needed to boot. Then you run your apps and they are copied to the jffs2. You can use df and look in /media/jffs2 to see what files are on the jffs2. If you accidentially add a file you don't need, just delete it from /media/flash.

After the system is booted and exersised and the jffs2 tweaked for busybox etc, it only needs to be shut down and then the jffs2 should be bootable standalone.

It would also be possible to support apt-get upgrades, which upgrade both the disk *and* the flash simulantaneously. This would be a special mode in which /media/flash is configured to be read-only for unionfs, and rootsync watches for file/directory removals/modifies, and makes sure that the flash and disk are kept in sync, but does not add any newly accessed files to the flash. So when apt downloads a .deb, that file is written only to /media/disk; when the deb is unpacked and changes /bin/ls, which is present in /media/flash already, that file is changed both on /media/flash and on /media/disk.

Open questions


The plan is to investigate whether this will work by building a prototype that consists of an "flash" directory, and a directory containing a debootstrapped system. Union these together, and use inotify to detect file accesses, copying the accessed files over to the "flash" directory. Then the debootstrapped directory can be removed from the union to see how well the "flash" directory works. Playing around with this prototype will hopefully turn up any big problems.

An early version of this prototype is now available, for now it's in git at http://git.kitenet.net/?p=joey/src.git;a=blob;f=misc/unreleased/rootsync/rootsync


Joey Hess <joeyh@debian.org> is planning to work on this.