Emdebian root filesystem
The root filesystem is a basic set of packages needed to provide a usable login environment around a kernel and kernel modules. The rootfs must be extensible to a full system so normal packaging tools need to be supported.
The main Debian root filesystem is based on 'Essential' -
a collection of packages that contain:
Essential: yes in debian/control and
although small in Debian terms, it is still much too large for
Emdebian uses several methods to reduce this size:
Drop the Essential tag
dpkg and apt have special behaviour for packages that contain the tag - tending to bring in the rest of the entire Debian 'Essential' set. Emdebian therefore removes all 'Essential' tags from cross built packages to provide full flexibility. (This also means that you should test your new rootfs thoroughly as there is no guarantee that your list of packages actually works. emsandbox supports creating a chroot on the embedded device to provide for such testing.)
perl is huge (in embedded terms) but removing it has other consequences. Emdebian packages need patching to replace perl maintainer scripts and prevent calls to perl scripts from 'Essential' packages from postinst or prerm shell maintainer scripts. (The irony is that emdebian-tools is written, principally, in perl. emsandbox and associated scripts are written in shell and only use the perl support in emdebian-tools for operations on the build machine.)
debconf is written in perl so cdebconf can be used to replace it, written in C. cdebconf needs a little careful handling - it is not actually expecting to be installed without debconf so Emdebian builds a new package from the debconf source that includes the non-perl components and initialises the debconf template database.
busybox can implement most of the functionality of coreutils. Note that Emdebian has had problems getting the busybox implementation of dpkg to work with apt. Hence, the Emdebian busybox package does not implement dpkg, Emdebian uses the Debian dpkg, cross-built for Emdebian.
Other methods yet to be investigated include:
- Replace glibc (libc6) with uclibc
- Split the gconv data into individual packages along with the zoneinfo data from tzdata and finish development of a userspace tool that installs and updates translations for only those zones that are configured on that one device.
- ipkg can be a smaller alternative to dpkg and apt
Emdebian Rootfs packages
The current Emdebian rootfs uses multistrap to avoid the limitations with using debootstrap.
To reduce the workload on the target device, the standard debootstrap method was altered to create multistrap. Multistrap uses the unpacking method where each .deb is unpacked using dpkg, without running any maintainer scripts. Other adjustments are then made to the multistrap environment to support booting without packages that would normally be available in Debian (like perl). The multistrap process results in an almost complete filesystem with no .deb packages remaining.
Emdebian Grip can still be used with debootstrap but some packages can fail when a multistrap method would succeed.
debootstrap requires that there is at least a nominal split between "base" and "required" packages and it is advisable to retain a similar split as with normal debootstrap - "required" for packages that debootstrap can unpack directly and "base" for packages that need to be unpacked separately.
Creating the rootfs
Emdebian expects that most users will want to customise their rootfs and the packages contained in the basic rootfs outlined above are being continually updated as new versions are uploaded to Debian. Therefore, there is no static link to a downloadable root filesystem for Emdebian.
multistrap works from prebuilt binary packages and so creating a root filesystem requires that the full set of packages are available in a repository that multistrap can use. If you want different functional changes from those used in Emdebian, use apt-get source and dpkg-buildpackage to create the renamed packages and then create your own repository (e.g. with reprepro).
Configuring the root filesystem
The Emdebian rootfs, as generated by multistrap is not necessarily fully configured - packages are unpacked and certain support files are created but none of the packages are configured. This last stage is the only process that must be run on the actual device before the first boot, using the dpkg --configure -a command which requires a working chroot environment. Typically, configuration is done from some kind of minimal bootloader environment that has sufficient support for mounting subsystems like proc and filesystems like the root filesystem partition and can chroot into the root filesystem. This method means that the majority of the work of creating the root filesystem can be done on the build machine.
Back to the Emdebian Project homepage.