Skip to main content

ext4: The Linux Workhorse Filesystem

Summary
Explore ext4, the default Linux filesystem with journaling, extents, and proven reliability. Learn how ext4 protects your data.

Why ext4 is still the default

ext4 is not the fastest filesystem (often XFS for large sequential writes), not the most feature-rich (Btrfs, ZFS), and not the newest design. It is the one distributions still ship for root volumes because it is simple, mature, and boring in the best way: journaling recovery, extents, and a well-understood failure model.

Evolution: ext2 → ext3 → ext4

  • ext2 (1993) — basic layout, no journal; fast, risky on crash
  • ext3 (2001) — journaling for crash recovery
  • ext4 (2008) — extents, delayed allocation, larger files/volumes, better allocation

Journaling

Without a journal, an unclean shutdown can leave bitmaps and inodes half-updated. Recovery means a full fsck — minutes to hours on large volumes. ext4 writes planned metadata (and optionally data) to a journal first, then commits. On remount it replays incomplete transactions instead of walking the whole disk.

Journal modes

ModeWhat is journaledTrade-off
journalData + metadataSafest, slowest (write amplification)
ordered (default)Metadata; data written firstBalanced safety and speed
writebackMetadata onlyFastest; data may be stale after crash
code
sudo tune2fs -o journal_data /dev/sda1 # Full data journaling

Extents and delayed allocation

ext3 tracked individual blocks — a 100 MB file could need tens of thousands of pointer entries. ext4 uses extents: (start_block, length) runs. Contiguous regions collapse to one record, which cuts metadata size, improves large-file I/O, and reduces fragmentation.

Delayed allocation waits until writeback to pick blocks, so the allocator sees larger, more contiguous requests instead of allocating on every write().

Limits (typical 4 KiB blocks)

  • Max file ≈ 16 TiB
  • Max volume ≈ 1 EiB
  • Filename length 255 bytes

Block groups

ext4 partitions the volume into block groups — each with its own bitmaps, inode table, and data region. That enables parallel allocation, localizes damage, and keeps related files nearby on disk.

Each group roughly contains:

  1. Superblock — only in group 0, 1, and groups that are powers of 3, 5, or 7
  2. Group descriptors — free counts and bitmap locations for every group
  3. Block bitmap — free/used data blocks
  4. Inode bitmap — free/used inodes
  5. Inode table — fixed-size inode records
  6. Data blocks — file and directory contents
code
sudo dumpe2fs /dev/sda1 | head -50 sudo debugfs /dev/sda1 # debugfs: stats

Flex block groups

flex_bg packs metadata from several groups (often 16) so superblocks, bitmaps, and inode tables sit closer together — better sequential metadata I/O and larger contiguous free regions for data.

code
sudo dumpe2fs /dev/sda1 | grep -i flex # Flex block group size: 16

Creating and managing

code
# Basic sudo mkfs.ext4 /dev/sdb1 # Labeled, less reserved space, RAID stride, SSD discard sudo mkfs.ext4 -L "MyData" \ -m 1 \ -O extent,flex_bg \ -E stride=32,stripe-width=64,discard \ /dev/sdb1

Tuning

code
sudo tune2fs -l /dev/sdb1 sudo tune2fs -m 1 /dev/sdb1 # reserved blocks % sudo tune2fs -c 50 /dev/sdb1 # mount count before fsck sudo tune2fs -i 180 /dev/sdb1 # check interval (days) sudo tune2fs -L "BackupDrive" /dev/sdb1

Mount options

code
mount -o noatime,nodiratime /dev/sdb1 /mnt # skip atime updates mount -o discard /dev/sdb1 /mnt # TRIM (or fstrim) mount -o errors=remount-ro /dev/sdb1 /mnt

Performance and maintenance

code
tune2fs -O dir_index /dev/sdb1 # hashed directories tune2fs -J size=400 /dev/sdb1 # larger journal (DBs) sudo e2fsck -f /dev/sdb1 # offline check sudo resize2fs /dev/sdb1 100G # grow (online when supported) sudo e4defrag /dev/sdb1 sudo e2fsck -b 32768 /dev/sdb1 # backup superblock

When to use ext4

Good fit: root filesystems, general-purpose volumes, production hosts that value stability over fancy features.

Prefer something else when you need: snapshots or send/receive (Btrfs/ZFS), built-in checksums and self-healing (ZFS/Btrfs), compression by default (Btrfs/ZFS), multi-device pools (ZFS/Btrfs), or Windows interoperability (exFAT/NTFS).

Featureext4XFSBtrfsZFS
MaturityHighHighMediumHigh
ThroughputHighVery highMediumMedium
FeaturesModestModestRichRich
Operational simplicityHighestHighLowerLowest

Advanced knobs

  • Inline data — tiny files stored inside the inode
  • Metadata checksumstune2fs -O metadata_csum detects metadata corruption (not full data scrubbing)
  • Lazy init — faster mkfs with background inode/table zeroing

Monitoring and recovery

code
cat /sys/fs/ext4/sdb1/lifetime_write_kbytes sudo extundelete /dev/sdb1 --restore-all # best-effort undelete sudo e2fsck -y /dev/sdb1

Practices that matter

  1. Keep ordered journal mode unless you have a measured reason to change.
  2. Leave 10–20% free so allocation stays contiguous.
  3. Prefer UUIDs in fstab over /dev/sdX names.
  4. Schedule checks; never treat the journal as a substitute for backups.

ext4 stays the Linux default because its failure modes and tools (e2fsck, tune2fs, debugfs) are well understood. Feature-rich filesystems win specialized jobs; for “make a reliable root volume,” ext4 still wins on simplicity.

If you found this explanation helpful, consider sharing it with others.

Mastodon