F2FS is a log-structured Linux file system designed by Samsung for NAND flash (Linux 3.8, 2013). It is used for Android /data partitions on many phones and for SD cards, eMMC and SSDs, and it is actively developed.
Overview
F2FS divides the volume into a superblock area, a checkpoint area, the Segment Information Table (SIT), the Node Address Table (NAT), the Segment Summary Area (SSA) and a main area that holds node and data segments. The NAT maps node IDs to block addresses, so updating a file does not rewrite its parent index. Data is written with multi-head logging that separates hot, warm and cold data.
Inodes hold inline data and inline extended attributes where space allows; directories are hash-based. The superblock has a magic number at byte offset 1024.
History
Developed by Samsung (Jaegeuk Kim) and merged in Linux 3.8 (2013).
Compression, fs-verity and casefolding were added in later releases.
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.
Data Addresses
Offset
Size
Type
Field
Notes
360 + extra + 4 * i
4
u32 LE
–
nidAt + 4 * k
4
u32 LE
Nid
Data Addresses
Offset
Size
Type
Field
Notes
4 * i
4
u32 LE
0
4 * i
4
u32 LE
Child
F2fs File System
Offset
Size
Type
Field
Notes
0x84
4
u32 LE
Flags
0x9C
4
u32 LE
Sit Bytes
0xA0
4
u32 LE
Nat Bytes
F2fs File System
Offset
Size
Type
Field
Notes
0x10
4
u32 LE
Log Block
0x14
4
u32 LE
Log Blocks Per Seg
0x44
4
u32 LE
Segments Main
0x4C
4
u32 LE
Cp Addr
0x50
4
u32 LE
Sit Addr
0x54
4
u32 LE
Nat Addr
0x5C
4
u32 LE
Ain Addr
0x60
4
u32 LE
Root Ino
0x680
4
u32 LE
Cp Payload
F2fs File System
Offset
Size
Type
Field
Notes
0x0
8
u64 LE
Version
0x88
4
u32 LE
Total
Get Children
Offset
Size
Type
Field
Notes
0x3
1
u8
–
0x10
8
u64 LE
Size
0x50
4
u32 LE
Encrypted
Inode Address Count
Offset
Size
Type
Field
Notes
0x3
1
u8
–
0x16A
2
u16 LE
–
Label
Offset
Size
Type
Field
Notes
0x8
8
u64 LE
User
0x10
8
u64 LE
Valid
Label
Offset
Size
Type
Field
Notes
0x24
8
u64 LE
Total Bytes
0x6C
16
bytes
Volume Serial
Make Entry
Offset
Size
Type
Field
Notes
0x0
2
u16 LE
Ode
0x3
1
u8
–
0x4
4
u32 LE
–
0x8
4
u32 LE
–
0x10
8
u64 LE
Size
0x50
4
u32 LE
Flags
Parse Dentries
Offset
Size
Type
Field
Notes
0x4
4
u32 LE
Ino
0x8
2
u16 LE
Length
0xA
1
u8
Type
Read Journals
Offset
Size
Type
Field
Notes
e
4
u32 LE
–
sitAt
2
u16 LE
Sits
e + 4
74
bytes
–
Read Journals
Offset
Size
Type
Field
Notes
e
4
u32 LE
Nid
journalAt
2
u16 LE
Nats
e + 4 + 5
4
u32 LE
Address
Read Node
Offset
Size
Type
Field
Notes
0x3
1
u8
–
0x168
2
u16 LE
–
Read Superblock
Offset
Size
Type
Field
Notes
0x0
4
u32 LE
–
0x10
4
u32 LE
Log
0x14
4
u32 LE
Log Seg
Volume Details
Offset
Size
Type
Field
Notes
0x0
8
u64 LE
–
0x94
4
u32 LE
–
Volume Details
Offset
Size
Type
Field
Notes
0x4
2
u16 LE
–
0x6
2
u16 LE
–
0x884
4
u32 LE
–
Probe
Offset
Size
Type
Field
Notes
0x4
2
u16 LE
Variant
0x6
2
u16 LE
Variant
0x10
4
u32 LE
Log
0x24
8
u64 LE
Blocks
Other fields read
Read in
Offset
Size
Type
Field
Notes
F2fs File System
0x0
8
u64 LE
–
Node Address
e + 5
4
u32 LE
–
Read Journals
0x8C
4
u32 LE
Start Sum
Read Node
_blockSize – 24
4
u32 LE
–
Unix Time
at
8
u64 LE
Seconds
Constants
F2fs File System
Name
Value
Type
Notes
Magic
0xF2F52010
uint
NatEntriesPerBlock
455
int
SitEntriesPerBlock
55
int
AddrsPerBlock
1018
int
DentriesPerBlock
214
int
EncryptFlag
0x800
uint
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.