Enhanced Read-Only File System (EROFS) lands in Yocto

The upcoming Yocto 3.4 release will contain a small contribution by us. Over the last two years we learned to love EROFS, so we decided to add support for it to Yocto (commit).

Usually when one wants a compressed read-only filesystem for Linux, squashfs is a good choice. It has been around since almost two decades and offers a wide range if different compression algorithms.

Starting with version 5.4, Linux supports a new filesystem that is optimized for compression and read-only storage, EROFS. Compared to squashfs it offers novel techniques such as fixed output size compression and avoids usage of buffer heads. This yields better read throughput with comparable compression ratio. We will post another write-up soon which compares squashfs and EROFS in detail.

EROFS currently supports three compression algorithms, none, lz4 and lz4hc. When EROFS is used as target filesystem in Yocto, one of these has to be selected, just like for squashfs. Just extend the IMAGE_FSTYPES variable with either erofs, erofs-lz4 or erofs-lz4hc. The resulting filesystem image file can be used just like a squashfs image on top of any block device.

Don’t forget to enable EROFS in your kernel config, though! Set at least CONFIG_EROFS_FS and CONFIG_EROFS_FS_ZIP in your kernel configuration.