F2FS (Flash-Friendly File System)

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

OffsetSizeTypeFieldNotes
360 + extra + 4 * i4u32 LE–
nidAt + 4 * k4u32 LENid

Data Addresses

OffsetSizeTypeFieldNotes
4 * i4u32 LE0
4 * i4u32 LEChild

F2fs File System

OffsetSizeTypeFieldNotes
0x844u32 LEFlags
0x9C4u32 LESit Bytes
0xA04u32 LENat Bytes

F2fs File System

OffsetSizeTypeFieldNotes
0x104u32 LELog Block
0x144u32 LELog Blocks Per Seg
0x444u32 LESegments Main
0x4C4u32 LECp Addr
0x504u32 LESit Addr
0x544u32 LENat Addr
0x5C4u32 LEAin Addr
0x604u32 LERoot Ino
0x6804u32 LECp Payload

F2fs File System

OffsetSizeTypeFieldNotes
0x08u64 LEVersion
0x884u32 LETotal

Get Children

OffsetSizeTypeFieldNotes
0x31u8–
0x108u64 LESize
0x504u32 LEEncrypted

Inode Address Count

OffsetSizeTypeFieldNotes
0x31u8–
0x16A2u16 LE–

Label

OffsetSizeTypeFieldNotes
0x88u64 LEUser
0x108u64 LEValid

Label

OffsetSizeTypeFieldNotes
0x248u64 LETotal Bytes
0x6C16bytesVolume Serial

Make Entry

OffsetSizeTypeFieldNotes
0x02u16 LEOde
0x31u8–
0x44u32 LE–
0x84u32 LE–
0x108u64 LESize
0x504u32 LEFlags

Parse Dentries

OffsetSizeTypeFieldNotes
0x44u32 LEIno
0x82u16 LELength
0xA1u8Type

Read Journals

OffsetSizeTypeFieldNotes
e4u32 LE–
sitAt2u16 LESits
e + 474bytes–

Read Journals

OffsetSizeTypeFieldNotes
e4u32 LENid
journalAt2u16 LENats
e + 4 + 54u32 LEAddress

Read Node

OffsetSizeTypeFieldNotes
0x31u8–
0x1682u16 LE–

Read Superblock

OffsetSizeTypeFieldNotes
0x04u32 LE–
0x104u32 LELog
0x144u32 LELog Seg

Volume Details

OffsetSizeTypeFieldNotes
0x08u64 LE–
0x944u32 LE–

Volume Details

OffsetSizeTypeFieldNotes
0x42u16 LE–
0x62u16 LE–
0x8844u32 LE–

Probe

OffsetSizeTypeFieldNotes
0x42u16 LEVariant
0x62u16 LEVariant
0x104u32 LELog
0x248u64 LEBlocks

Other fields read

Read inOffsetSizeTypeFieldNotes
F2fs File System0x08u64 LE–
Node Addresse + 54u32 LE–
Read Journals0x8C4u32 LEStart Sum
Read Node_blockSize – 244u32 LE–
Unix Timeat8u64 LESeconds

Constants

F2fs File System

NameValueTypeNotes
Magic0xF2F52010uint
NatEntriesPerBlock455int
SitEntriesPerBlock55int
AddrsPerBlock1018int
DentriesPerBlock214int
EncryptFlag0x800uint
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.