F2FS

Also known as: Flash-Friendly File System

On this page 8

F2FS (Flash-Friendly File System) is a log-structured Linux filesystem designed for NAND flash storage such as eMMC, UFS, SD cards and SSDs. Developed at Samsung and merged into the Linux kernel in version 3.8, it organizes writes so that they arrive at the device sequentially and in large units, which suits the way flash translation layers work and reduces internal write amplification.

Within the Filesystem topic of Linux, F2FS sits between general-purpose designs such as ext4 and XFS and copy-on-write systems such as Btrfs. It is the default data partition format on many Android phones, and it is also used on single-board computers, embedded devices and laptops where flash endurance and random write latency matter more than advanced volume management.

How F2FS organizes data on flash

F2FS writes new data to free space at the end of an active log instead of overwriting blocks in place. The volume is divided into 4 KiB blocks, grouped into 2 MiB segments, which are grouped into sections and zones. Sections are the unit of garbage collection, and zones can be aligned with the erase or allocation units of the underlying device.

The on-disk layout separates fixed-location metadata from the main area. A pair of checkpoint areas records a consistent filesystem state, the Segment Information Table (SIT) tracks valid blocks per segment, the Node Address Table (NAT) maps node IDs to physical addresses, and the Segment Summary Area (SSA) records which node owns each block in the main area.

The following table summarizes the main on-disk areas and the role each one plays.

AreaContentsPurpose
SuperblockVolume geometry and feature flagsIdentifies and describes the filesystem
Checkpoint (CP)Two alternating consistent statesCrash recovery without a full journal
SITValid block counts and bitmaps per segmentGuides allocation and cleaning
NATNode ID to block address mappingStops the wandering tree problem
SSAOwner information for each main-area blockLets the cleaner find parent nodes
Main areaNode blocks and data blocksHolds inodes, indexes and file contents
Main on-disk areas of an F2FS volume

The NAT is the central design choice. In a classic log-structured filesystem, moving one data block forces updates of its indirect block, then of the inode, then of the inode map, a cascade known as the wandering tree problem. F2FS stops the cascade by referring to nodes through NAT indirection, so relocating a block updates only its direct node and one NAT entry.

Multi-head logging and hot and cold separation

F2FS keeps six active logs at the same time and assigns each write to a log according to its expected lifetime. This multi-head logging places short-lived and long-lived blocks in different segments, so that segments tend to become either fully invalid or fully valid, which makes garbage collection much cheaper.

LogBlock typeTypical contents
Hot nodeNodeDirect node blocks of directories
Warm nodeNodeDirect node blocks of regular files
Cold nodeNodeIndirect node blocks
Hot dataDataDirectory entries and small frequently changed data
Warm dataDataOrdinary file data
Cold dataDataMultimedia, moved blocks and data marked cold
The six default logs and their typical contents

Administrators can steer classification with extension lists set by mkfs.f2fs, so files such as .mp4 or .jpg go straight to the cold log. When free space runs short, F2FS switches from normal append logging to threaded logging, which writes into the invalid holes of dirty segments. This adaptive logging trades some sequentiality for lower cleaning cost and keeps latency acceptable on a nearly full volume.

Key features and mount options

Beyond its layout, F2FS offers a feature set aimed at mobile and embedded workloads. Most features are enabled at format time with mkfs.f2fs -O, while others are selected through mount options in fstab or on the mount command line.

  • Inline data and inline xattr store very small files and extended attributes inside the inode block, saving space and I/O.
  • Transparent compression with LZO, LZ4 or Zstandard works on clusters of blocks and is selected per file or per extension.
  • Atomic writes let SQLite commit a batch of pages as one unit, which removes much of the journal traffic on Android.
  • Native encryption through fscrypt and fs-verity integrity protection support verified boot and file-based encryption.
  • Casefolding provides case-insensitive lookups for compatibility with other platforms.
  • Zoned device support allows F2FS to run on host-managed SMR drives and ZNS SSDs.

The table below lists frequently used mount options and when each one is useful.

OptionEffectWhen to use it
background_gc=onEnables idle-time cleaningDefault for most systems
discardIssues trim commands for freed blocksFlash devices with good trim handling
compress_algorithm=zstdSelects the compression methodRead-heavy data that compresses well
atgcAge-threshold garbage collectionVolumes with mixed data lifetimes
checkpoint=disableSuspends checkpoints temporarilyOver-the-air updates with rollback
fsync_mode=posixDefault fsync behaviorGeneral workloads
Common F2FS mount options

F2FS compared with other Linux filesystems

F2FS is optimized for flash write patterns, while ext4 and XFS are update-in-place designs that rely on the device firmware to handle flash management. Btrfs and bcachefs are copy-on-write systems with checksums and snapshots. The comparison below shows where each design fits.

FilesystemWrite modelStrengthMain limitation
F2FSLog-structured with multi-head logsFlash endurance and small random writesNo snapshots or data checksums
ext4Update in place with journalMaturity and broad toolingNo compression or flash awareness
XFSUpdate in place with journalLarge files and parallel I/OCannot shrink
BtrfsCopy-on-writeSnapshots, checksums and RAIDHigher metadata overhead
bcachefsCopy-on-writeTiering and checksumsYoung code base
F2FS compared with related Linux filesystems

The difference matters most on devices with simple flash controllers, such as eMMC and SD cards, where firmware cannot hide random writes well. On a high-end NVMe SSD with a large overprovisioned area, the measurable advantage of F2FS over ext4 is often small and workload-dependent.

Creating, checking and maintaining an F2FS volume

F2FS is managed with the f2fs-tools package. A volume is created with mkfs.f2fs, for example mkfs.f2fs -l data -O extra_attr,compression /dev/sdb1, and mounted with the standard mount -t f2fs command. lsblk and blkid report the filesystem type as f2fs.

Consistency is protected mainly by the checkpoint mechanism and roll-forward recovery: after a crash, F2FS returns to the last valid checkpoint and then replays fsynced node blocks written after it. The offline checker fsck.f2fs repairs metadata when this is not enough, and resize.f2fs grows an unmounted volume, with shrinking supported only in recent tool versions.

Limitations and common mistakes

F2FS performs best with enough free space for cleaning. On a volume that is more than about 90 percent full, garbage collection runs often, and write latency can rise sharply. The table connects frequent symptoms with their causes and fixes.

SymptomLikely causeRemedy
Write stalls on a full volumeForeground garbage collectionKeep at least 10 to 20 percent free
Mount fails after kernel downgradeNewer format features enabledMatch features to the oldest kernel
Poor results on a hard diskLog-structured layout fragments readsUse ext4 or XFS on rotating media
Compressed files use full spaceSpace is reserved unless releasedRelease blocks with the ioctl if needed
Typical F2FS problems and remedies

F2FS also lacks data checksums, snapshots and built-in RAID, so it does not replace Btrfs or LVM where those features are required. A further mistake is enabling every format feature by default: options such as compression or casefolding cannot always be removed later, and older kernels or bootloaders may refuse the volume.

In simple terms

Flash memory in phones and memory cards dislikes being rewritten in small scattered pieces. Each rewrite forces the chip to copy and erase larger areas, which slows it down and wears it out.

F2FS is a way of storing files that respects this habit. Instead of changing data where it already sits, it adds new data to the end of a running list, a bit like writing a diary instead of erasing old pages. It also keeps short-lived and long-lived data apart, so cleaning up old space later takes less work. The result is steadier speed and longer flash life.

A practical example

A team building a Linux-based industrial data logger uses a 32 GB industrial eMMC module. Their first prototype with ext4 writes small sensor records every second, and endurance tests predict that the module will reach its rated write limit in about three years.

They reformat the data partition with mkfs.f2fs -O extra_attr,compression, mount it with compress_algorithm=lz4 and background_gc=on, and keep the partition below 70 percent usage. In the repeated test, the device reports noticeably lower write amplification, and the projected service life now exceeds the planned eight-year deployment. The team keeps ext4 on the small read-only boot partition, where F2FS offers no benefit.