EROFS
data.c EROFS source file | |
Developer(s) | Huawei
|
---|---|
Full name | Enhanced Read-Only File System |
Introduced | 2018 |
Repository | kernel module: git.kernel.org: fs/erofs erofs-utils: git.kernel.org: xiang/erofs-utils.git |
Documentation | git.kernel.org: filesystems/erofs.rst |
Limits | |
Max. file size | |
Max. number of files |
|
Max. filename length | 255 bytes |
Features | |
Dates recorded | Create (version 2 only) |
Date resolution | 1 ns |
Attributes | POSIX, xattr |
File system permissions | POSIX, ACL |
Transparent compression | Yes (LZ4) |
Other | |
Supported operating systems | Linux |
Enhanced Read-Only File System is a efficient high-performance read only filesystem developed by Gao Xiang. It features in-place decompression for maximum efficiency. EROFS has features which makes it superior to other read-only filesystems like squashfs on devices with limited memory. LZ4 is currently the only supported compression algorithm.
EROFS was first introduced to the Linux kernel's "staging" area in 2018. It became part of the mainline Linux kernel when Linux 5.4 was released in November 2019. The user-space utilities are available in erofs-utils.git.
Features[edit]
- 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
- Transparent LZ4 compression. 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]
Compressed EROFS images can be created with mkfs.erofs
which comes as a part fo the erofs-utils
package (actually, it's the only binary in that package). The code can be aqcuired from git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git.
All the distributions have erofs-utils
as of September 2020. It is unlikely that you will need to compile erofs-utils
yourself at this time.
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 if your distribution provides a version prior to lz4 <=1.9.0:
git clone https://github.com/lz4/lz4.git cd lz4/ make 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://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git -b dev cd erofs-utils/ ./autogen.sh ./configure --with-lz4-incdir=/usr/local/include/ --with-lz4-libdir=/usr/local/lib make su -c 'make install'
HOWTO Use EROFS[edit]
The basic syntax for creating a EROFS image is:
mkfs.erofs -zlz4hc myimage.erofs folder1/ folder2/
-z
for lz4 required even though it is currently the only supposed compression algorithm.
A mounting EROFS images is done the same way you would mount a ISO image or any other file as a read only file system:
sudo mount -o loop myimage.erofs /mnt/tmp
The kernel ring buffer (dmesg
) shows notifications with a erofs image is mounted:
erofs: (device loop2): mounted with root inode @ nid 38.
Mount options[edit]
fault_injection=%d | Enable fault injection in all supported types with specified injection rate. Supported injection type:
| ||||||
(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; |
In most cases the standard -o loop
option is enough to mount a EROFS image. However, you can use the different options listed above to tweak it:
mount -o loop,cache_strategy=readahead myimage.erofs /mnt/tmp
Technical details[edit]
EROFS supports 4KB fixed-output clustersize transparent file compression.
|---- Variant-Length Extent ----|-------- VLE --------|----- VLE ----- clusterofs clusterofs clusterofs | | | logical data _________v_______________________________v_____________________v_______________ ... | . | | . | | . | ... ____|____.________|_____________|________.____|_____________|__.__________|____ |-> 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.
Enable comment auto-refresher