Advanced AOSP Subsystems
3 min read

EXT4

EXT4 in the Android Ecosystem

EXT4 (Fourth Extended Filesystem) is a deeply mature, stable, and widely used file system in the Linux kernel. While F2FS has taken over the /data partition on many modern Android devices, EXT4 remains the standard for read-only or read-mostly partitions like /system, /vendor, and /product.

EXT4 Use in Android (System, Vendor Partitions)

Android's OS partitions are built as EXT4 images during the AOSP build process. Because these partitions are typically mounted as read-only (ro), the write-amplification issues that affect flash memory on EXT4 are largely irrelevant here.

EXT4 is chosen for these partitions due to:

  • Rock-solid stability: Decades of testing in enterprise environments.
  • Efficient read performance: Extents map contiguous blocks, making sequential reads extremely fast.
  • Mature tooling: Tools like make_ext4fs and e2fsck are robust and heavily optimized.

Extents and Block Mapping

Older file systems mapped file data using direct and indirect block pointers, which became inefficient for large files. EXT4 uses Extents. An extent is a contiguous range of physical blocks. A single extent descriptor can map up to 128MB of contiguous space, significantly reducing metadata overhead and improving read/write throughput.

Journaling Modes

EXT4 is a journaling file system, meaning it keeps a "journal" of pending changes to protect against corruption during power failures. EXT4 supports three journaling modes:

  1. Writeback (data=writeback): Only metadata is journaled. File data is written to the main filesystem directly. This is the fastest mode but carries a risk of stale data appearing in files after a crash.
  2. Ordered (data=ordered): The default mode. Only metadata is journaled, but EXT4 guarantees that file data is written to the main filesystem before its associated metadata is committed to the journal.
  3. Journal (data=journal): Both metadata and file data are written to the journal before being committed to the main filesystem. This is the safest but slowest mode, as all data is written twice.

EXT4 vs. F2FS Trade-offs

When choosing between EXT4 and F2FS for a specific partition, Android OEMs weigh the following trade-offs:

FeatureEXT4F2FS
Design TargetMagnetic spinning disksFlash memory (NAND/eMMC/UFS)
Write PatternIn-place updatesLog-structured (Append-only)
Random Write SpeedLower (suffers from high latency)High (converted to sequential writes)
FragmentationLow over timeHigh, requires Garbage Collection
Best Use Case/system, /vendor (Read-only)/data (Heavy random writes)

Practical Commands

You can inspect EXT4 filesystems using standard Linux utilities available via ADB.

Viewing EXT4 Superblock information:

adb shell tune2fs -l /dev/block/bootdevice/by-name/system

Checking filesystem integrity:

adb shell e2fsck -n /dev/block/bootdevice/by-name/persist

Remounting system as read-write (on engineering builds):

adb root
adb remount