From LinuxReviews
Jump to navigationJump to search

Enhanced Read-Only File System is a efficient high-performance read only filesystem. It features in-place decompression for maximum efficiency. Only LZ4 compression is supported at this time. EROFS has features which makes it superior to other read-only filesystems like squashfs on devices with limited memory.

EROFS has been available in the mainline Linux kernel's "staging" area since 2018.

Features[edit | edit source]

  • Little-endian on-disk design.
  • 4KB block size. This limits the total possible capacity of a EROFS filesystem to 16 TB.
  • Optional support for extended attributes (xattrs)
  • Supports POSIX.1e ACLs by using xattrs
  • Fixed-output compression for high performance
  • LZ4 is the only supported algorithm

EROFS supports who different inode versions:

v1 v2
Inode metadata size: 32 bytes 64 bytes
Max file size 4 GB 16 EB (also limited by max. vol size)
Max uids/gids 65536 4294967296
File creation time no yes (64 + 32-bit timestamp)
Max hardlinks 65536 4294967296
Metadata reserved 4 bytes 14 bytes

User-space utilities[edit | edit source]

Compressed EROFS images can be created with mkfs.erofs which is a part of erofs-utils (actually, it's the only binary in that package as of now). The code can be aqcuired from xiang/erofs-utils.git.

erofs-utils requires lz4 and it has issues with lz4 <=1.8.3. You may want to compile both lz4 and erofs-utils from git:

git clone
cd lz4/
su -c 'make install'

make install will by default install to /usr/local/ which means lz4's include and library directories need to be specified when compiling erofs-utils:

git clone git:// -b dev
cd erofs-utils/
./configure --with-lz4-incdir=/usr/local/include/ --with-lz4-libdir=/usr/local/lib
su -c 'make install'

The basic syntax for creating a EROFS image is:

mkfs.erofs -zlz4hc myimage.erofs.img folder1/ folder2/

While -z is required it is also the only currently supposed compression algorithm.

Mount options[edit | edit source]

fault_injection=%d Enable fault injection in all supported types with specified injection rate. Supported injection type:
Type_Name Type_Value
FAULT_KMALLOC 0x000000001
FAULT_READ_IO 0x000000002
(no)user_xattr Setup Extended User Attributes. Note: xattr is enabled by default if CONFIG_EROFS_FS_XATTR is selected.
(no)acl Setup POSIX Access Control List. Note: acl is enabled
cache_strategy=%s Select a strategy for cached decompression.

disabled: In-place I/O decompression only;
readahead: Cache the last incomplete compressed physical cluster for further reading. It still does in-place I/O decompression for the rest compressed physical clusters;
readaround: Cache the both ends of incomplete compressed physical clusters for further reading. It still does in-place I/O decompression for the rest compressed physical clusters.

In most cases the standard -o loop option is enough to mount a EROFS image:

mount -o loop myfiles.erofs.img /mnt/tmp

Technical details[edit | edit source]

EROFS supports 4KB fixed-output clustersize transparent file compression.

         |---- Variant-Length Extent ----|-------- VLE --------|----- VLE -----
         clusterofs                      clusterofs            clusterofs
         |                               |                     |   logical data
... |    .        |             |        .    |             |  .          | ...
    |-> cluster <-|-> cluster <-|-> cluster <-|-> cluster <-|-> cluster <-|
         size          size          size          size          size
          .                             .                .                   .
           .                       .               .                  .
            .                  .              .                .
         ... |             |             |             | ... physical data
             |-> cluster <-|-> cluster <-|-> cluster <-|
                  size          size          size

A physical cluster can contain a maximum of 4KB compressed or uncompressed data. Logical clusters have a on-disk index which describes it's physical cluster address, cluster type and other details.

Development[edit | edit source]

EROFS is developed by Chinese technology giant Huawei. It is free software and the source code is available in the kernel git tree. The user-space utilities are available in erofs-utils.git.

Add your comment
LinuxReviews welcomes all comments. If you do not want to be anonymous, register or log in. It is free.