UBIFS runs on top of UBI volumes on raw NAND flash and replaced JFFS2 on larger chips (Linux 2.6.27, 2008). It is common in routers, set-top boxes, cameras and other embedded devices, and is a frequent target in chip-off flash recovery.
Overview
UBI maps logical eraseblocks to physical ones, handling wear leveling, and carries an erase-counter header and a volume identifier header per block. UBIFS stores its data in nodes inside those logical blocks and keeps an on-flash B+-tree index, a log and a journal for quick mounting. Nodes have a common header with magic 0x06101831, and data may be compressed (LZO, zlib, zstd).
History
Developed by Nokia engineers (Artem Bityutskiy and Adrian Hunter) and merged into Linux 2.6.27 (2008).
Structures
Offsets are in bytes from the start of the structure named in each heading. Field names are descriptive and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.
Is Ec Header
Offset
Size
Type
Field
Notes
0x0
1
u8
–
0x1
1
u8
–
0x2
1
u8
–
0x3
1
u8
–
0x4
1
u8
–
UBI version
0x10
4
u32 BE
Vid Offset
0x14
4
u32 BE
Data Offset
Parse
Offset
Size
Type
Field
Notes
0x10
4
u32 BE
Vid Offset
0x14
4
u32 BE
Data Offset
Parse
Offset
Size
Type
Field
Notes
0x8
4
u32 BE
Vol Id Raw
0xC
4
u32 BE
Lnum
0x2C
8
u64 BE
Sqnum
Has Ubifs Node
Offset
Size
Type
Field
Notes
p
4
u32 LE
–
p + 16
4
u32 LE
Len
p + 20
1
u8
Node Type
Constants
Ubi Image
Name
Value
Type
Notes
InternalVolStart
0x7FFFEFFF
uint
EcHdrSize
64
int
VidHdrSize
64
int
(volId, lnum) -> newest mapping.
Name
Value
Type
Notes
Step
4096
int
Ubifs File System Module
Name
Value
Type
Notes
NodeMagic
0x06101831
uint
Ubifs Reader
Name
Value
Type
Notes
NodeMagic
0x06101831
uint
ChSize
24
int
node types
Name
Value
Type
Notes
TypeIno
0
byte
TypeData
1
byte
TypeDent
2
byte
item (dentry) types
Name
Value
Type
Notes
ItypeReg
0
byte
ItypeDir
1
byte
ItypeLnk
2
byte
compression
Name
Value
Type
Notes
ComprNone
0
byte
ComprLzo
1
byte
ComprZlib
2
byte
ComprZstd
3
byte
BlockSize
4096
int
RootInode
1
uint
ScanCap
256L * 1024 * 1024
long
MaxFileBytes
512 * 1024 * 1024
int
MaxNodeLen
2L * 1024 * 1024
long
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.