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.
So 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
SELF images into a tarball to meet the requirements mentioned above:
In a
ELDK installation, the
SELF images can be found in the
/opt/eldk/<architecture>/images/
directory.
There is already a compressed ramdisk image in this directory,
which we will use (
ramdisk_image.gz
):
- Uncompress ramdisk image:
bash$ gzip -d -c -v /opt/eldk/ppc_8xx/images/ramdisk_image.gz >/tmp/ramdisk_image
/opt/eldk/ppc_8xx/images/ramdisk_image.gz: 61.4%
- Mount ramdisk image (
This requires root permissions!):
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:
# cd /mnt/tmp
# 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
cramfs
):
# tar -zcf /tmp/devices.tar.gz dev/
# cd /tmp
- Unmount ramdisk image:
bash# umount /mnt/tmp
We will use the
/tmp/rootfs.tar.gz
tarball as master file in all following experiments.