Read-only compressed filesystems
Compressing data is useful if you don't have quite enough storage to fit everything in. Both JFFS2 and UBIFS do on-the-fly data compression by default. However, if the files are never going to be written, as is usually the case with the root filesystem, you can achieve better compression ratios by using a read-only compressed filesystem. Linux supports several of these: romfs
, cramfs
, and squashfs
. The first two are obsolete now, so I will only describe SquashFS.
SquashFS
The SquashFS filesystem was written by Phillip Lougher in 2002 as a replacement for cramfs. It existed as a kernel patch for a long time, eventually being merged into mainline Linux in version 2.6.29 in 2009. It is very easy to use: you create a filesystem image using mksquashfs
and install it to the flash memory:
$ mksquashfs rootfs rootfs.squashfs
The resulting filesystem is read-only, so there is no mechanism for modifying any of the files at runtime. The only way...