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.
| Area | Contents | Purpose |
|---|---|---|
| Superblock | Volume geometry and feature flags | Identifies and describes the filesystem |
| Checkpoint (CP) | Two alternating consistent states | Crash recovery without a full journal |
| SIT | Valid block counts and bitmaps per segment | Guides allocation and cleaning |
| NAT | Node ID to block address mapping | Stops the wandering tree problem |
| SSA | Owner information for each main-area block | Lets the cleaner find parent nodes |
| Main area | Node blocks and data blocks | Holds inodes, indexes and file contents |
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.
| Log | Block type | Typical contents |
|---|---|---|
| Hot node | Node | Direct node blocks of directories |
| Warm node | Node | Direct node blocks of regular files |
| Cold node | Node | Indirect node blocks |
| Hot data | Data | Directory entries and small frequently changed data |
| Warm data | Data | Ordinary file data |
| Cold data | Data | Multimedia, moved blocks and data marked cold |
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.
| Option | Effect | When to use it |
|---|---|---|
background_gc=on | Enables idle-time cleaning | Default for most systems |
discard | Issues trim commands for freed blocks | Flash devices with good trim handling |
compress_algorithm=zstd | Selects the compression method | Read-heavy data that compresses well |
atgc | Age-threshold garbage collection | Volumes with mixed data lifetimes |
checkpoint=disable | Suspends checkpoints temporarily | Over-the-air updates with rollback |
fsync_mode=posix | Default fsync behavior | General workloads |
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.
| Filesystem | Write model | Strength | Main limitation |
|---|---|---|---|
| F2FS | Log-structured with multi-head logs | Flash endurance and small random writes | No snapshots or data checksums |
| ext4 | Update in place with journal | Maturity and broad tooling | No compression or flash awareness |
| XFS | Update in place with journal | Large files and parallel I/O | Cannot shrink |
| Btrfs | Copy-on-write | Snapshots, checksums and RAID | Higher metadata overhead |
| bcachefs | Copy-on-write | Tiering and checksums | Young code base |
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.
| Symptom | Likely cause | Remedy |
|---|---|---|
| Write stalls on a full volume | Foreground garbage collection | Keep at least 10 to 20 percent free |
| Mount fails after kernel downgrade | Newer format features enabled | Match features to the oldest kernel |
| Poor results on a hard disk | Log-structured layout fragments reads | Use ext4 or XFS on rotating media |
| Compressed files use full space | Space is reserved unless released | Release blocks with the ioctl if needed |
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.