You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EROFS is a high-performance read-only filesystem originally developed by
Huawei and now used extensively in AOSP. It offers features like
compression (LZ4, LZ4HC, LZMA, ZLIB, ZSTD), inline data, and reduced storage overhead,
making it ideal for read-only system images.
Create erofs file : > mkfs.erofs -z[compressor, level (optional)]
foo.erofs.img foo/
Extract erofs file: > fsck.erofs --extract=foo_extracted/ foo.erofs.img
Key notes:
- First 1024 bytes are reserved for the boot loader
- Header starts at 0x400 with E0F5E1E2
- Header can be more than 128 bytes if extra slots provided
- File format in little endian
- There is no standarized file extension. The official documentation
uses ".erofs.img"
- Checksum changes from version to version
HEADER / SUPERBLOCK:
> 4 bytes : Magic
> 4 bytes : Checksum
> 4 bytes : Feature
> 1 byte : Block size in bit shift
> 1 byte : Superblock extension
> 2 bytes : Root NID
> 8 bytes : Total valid i-node
> 8 bytes : Built time in timestamp
> 4 bytes : Nanoseconds (ns) component of timestamp
> 4 bytes : Total block count
> 4 bytes : Start block addr of metadata area
> 4 bytes : Start block of shared xattr area
> 16 bytes : UUID for volume
> 16 bytes : Filesystem label
> 4 bytes : Incompatible feature flag for kernel
> 2 bytes : Available compression algorithm
> 2 bytes : LZ4 max distance
> 2 bytes : Extra devices
> 2 bytes : Start address of external device table
> 1 byte : Directory block size 2^blkszbits+dirblkbits
> 1 byte : Total number of long xattr name prefixes
> 4 bytes : Start address of long xattr prefixes
> 8 bytes : NID of the special packed inode.
> 1 byte : xattr filter reserved
> 23 bytes : Reserved
Unblob structs the header until feature_incompact. The rest is labeled
as "reserved". Unblob parses the end offset by multiplying the block
size in bit shift with the block count.
Since the checksum is not consistent troughout versions, unblob matched
on block count (min 1), printable volume name, build time, build
time in ns and bit shift (min 9).
[Sources]
https://elixir.bootlin.com/linux/v6.14-rc6/source/fs/erofs/erofs_fs.hhttps://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/erofs/erofs_fs.h?h=v6.6https://erofs.docs.kernel.org/en/latest/core_ondisk.htmlhttps://www.kernel.org/doc/html/latest/filesystems/erofs.html
0 commit comments