Specifications
Instead, we create a separate tarball which contains only the device entries so we can use them when
necessary (with cramfs):
bash# tar -zcf /tmp/devices.tar.gz dev/
bash# cd /tmp
4.
Unmount ramdisk image:
bash# umount /mnt/tmp
5.
We will use the /tmp/rootfs.tar.gz tarball as master file in all following experiments.
9.5.1. Root File System on a Ramdisk
Ram disks are used very often to hold the root file system of embedded systems. They have several
advantages:
well-known•
well-supported by the Linux kernel•
simple to build•
simple to use - you can even combine the ramdisk with the Linux kernel into a single image file•
RAM based, thus pretty fast•
writable file system•
original state of file system after each reboot = easy recovery from accidental or malicious data
corruption etc.
•
On the other hand, there are several disadvantages, too:
big memory footprint: you always have to load the complete filesystem into RAM, even if only small
parts of are actually used
•
slow boot time: you have to load (and uncompress) the whole image before the first application
process can start
•
only the whole image can be replaced (not individual files)•
additional storage needed for writable persistent data•
Actually there are only very few situations where a ramdisk image is the optimal solution. But because they
are so easy to build and use we will discuss them here anyway.
In almost all cases you will use an ext2 file system in your ramdisk image. The following steps are needed to
create it:
Create a directory tree with the content of the target root filesystem. We do this by unpacking our
master tarball:
$ mkdir rootfs
$ cd rootfs
$ tar zxf /tmp/rootfs.tar.gz
1.
We use the genext2fs tool to create the ramdisk image as this allows to use a simple text file to
describe which devices shall be created in the generated file system image. That means that no root
permissions are required at all. We use the following device table rootfs_devices.tab:
#<name> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count>
/dev d 755 0 0 - - - - -
/dev/console c 640 0 0 5 1 - - -
/dev/fb0 c 640 0 0 29 0 - - -
/dev/full c 640 0 0 1 7 - - -
/dev/hda b 640 0 0 3 0 - - -
2.
9.5.1. Root File System on a Ramdisk 112