It is not an easy task to design the root file system
for an embedded system.
There are three major problems to be solved:
- what to put in it
- which file system type to use
- where to store and how to boot it
For now we will assume that the contents of the root file system
is aready known;
for example, it is given to us as a directory tree
or a tarball which contains all the required files.
We will also assume that our system is a typical resource-limited
embedded system so we will especially look for solutions where the
root file system can be stored on on-board flash memory or other
flash memory based devices like CompactFlash or SD cards, MMC or
USB memory sticks.
A widespread approach to build a root file system is to use some
Linux distribution (like the ELDK
) and to remove things not needed.
This approach may be pretty common, but it is almost always terribly
wrong. You also don't build a family home by taking a skyscraper and
Like a house, a root file system should be built bottom up, starting
from scratch and adding things you know you need. Never add anything
where you don't exactly know what it's needed for.
But our focus here is on the second item:
the options we have for
chosing a file system type and the consequences this has.
In all cases we will base our experiments on the same content of the
root filesystem; we use the images of the SELF
(Simple Embedded Linux Framework) that come with the ELDK
. In a first step we will transform the
images into a tarball to meet the requirements mentioned above:
In a ELDK
installation, the SELF
images can be found in the
There is already a compressed ramdisk image in this directory,
which we will use (
- Uncompress ramdisk image:
bash$ gzip -d -c -v /opt/eldk/ppc_8xx/images/ramdisk_image.gz >/tmp/ramdisk_image
Note: The following steps require root permissions!
- Mount ramdisk image:
bash# mount -o loop /tmp/ramdisk_image /mnt/tmp
- Create tarball;
to avoid the need for
root permissions in the following
steps we don't include the device files in our tarball:
bash# cd /mnt/tmp
bash# tar -zc --exclude='dev/*' -f /tmp/rootfs.tar.gz *
- Instead, we create a separate tarball which contains only the
device entries so we can use them when necessary (with
bash# tar -zcf /tmp/devices.tar.gz dev/
bash# cd /tmp
- Unmount ramdisk image:
bash# umount /mnt/tmp
We will use the
tarball as master file in all following experiments.