ext4 (fourth extended filesystem) is a journaling file system for Linux that serves as the default storage layer for most modern distributions. Developed as a direct successor to ext3, it significantly improves storage scalability, crash recovery, and read/write performance. It supports volume sizes up to 1 exabyte (EiB) and individual file sizes up to 16 terabytes (TiB), making it well suited for both everyday servers and high-capacity storage environments.
How it works
Traditional Linux file systems tracked file locations using indirect block mapping, which required the kernel to maintain a separate pointer for every single block of data. For large files, this created heavy metadata overhead and slowed down file deletion or truncation.
ext4 solves this bottleneck through three core mechanisms:
- Extents: Instead of mapping individual blocks, an extent maps a range of contiguous physical blocks using a single descriptor. A single extent in ext4 can represent up to 128 MiB of contiguous space (assuming a 4 KiB block size), drastically reducing metadata overhead.
- Journaling: Before committing changes to the main file system, ext4 records metadata updates—and optionally data—in a dedicated journal area. If a server loses power unexpectedly, the system replays the journal upon reboot to restore consistency without scanning the entire disk.
- Delayed and multiblock allocation: ext4 delays assigning physical blocks until data is actually flushed from memory to disk. Combining this with multiblock allocation allows the file system to group writes into contiguous chunks, improving throughput and minimizing fragmentation.
Example
To format a new block device as ext4, reserve minimal space for the root user on a non-system data drive, and mount it persistently, an administrator runs the following commands:
# Format the partition with ext4 and set reserved blocks to 1%
mkfs.ext4 -m 1 /dev/sdb1
# Create a mount point and attach the partition
mkdir -p /mnt/data
mount -t ext4 /dev/sdb1 /mnt/data
# Inspect or modify filesystem parameters later without unmounting
tune2fs -l /dev/sdb1
For production servers, you typically add the partition's UUID to /etc/fstab using the defaults,noatime options to avoid unnecessary disk writes every time a file is read.
What matters when choosing a server or hosting
When provisioning virtual private servers (VPS), cloud instances, or dedicated hardware, ext4 is usually the safest default for general-purpose workloads such as web servers, application hosts, and small-to-medium databases. Because it is mature and tightly integrated into the Linux kernel, it requires minimal tuning and recovers quickly from unclean reboots.
However, you should evaluate alternatives if your workload demands advanced storage features. ext4 lacks built-in volume management, native snapshots, copy-on-write data integrity checks, and transparent compression. If you run large database clusters, multi-disk storage arrays, or environments requiring instant point-in-time backups at the file system level, XFS or ZFS may be a better fit.
Common mistakes
- Leaving the default 5% reserved space on large data volumes: By default,
mkfs.ext4reserves 5% of blocks for the root user to prevent system lockups when a root partition fills up. On a multi-terabyte secondary data drive, this wastes hundreds of gigabytes. Reduce it to0%or1%usingtune2fs -m 1 /dev/sdX. - Running out of inodes: ext4 allocates a fixed number of inodes (file metadata slots) at creation time. Servers storing millions of tiny files—such as cache directories or mail queues—can hit 100% inode usage even when plenty of free gigabytes remain.
- Using
discardmount options unnecessarily on SSDs: Enabling continuous TRIM via thediscardoption in/etc/fstabcan degrade I/O performance on certain cloud block devices. Running a periodic scheduledfstrimtimer is generally preferred.
FAQ
Can I convert an existing ext3 file system to ext4 without losing data?
Yes. Because ext4 is backward-compatible with ext3, you can enable ext4 features on an existing partition using tune2fs -O extents,uninit_bg,dir_index /dev/sdX followed by a file system check (e2fsck). Existing files remain intact, while newly written files take advantage of extents.
How does ext4 compare to XFS for Linux servers?
ext4 excels at handling many small files, supports shrinking volumes offline, and offers fast file system checks. XFS scales better under heavy parallel I/O workloads and massive file sizes, though XFS partitions cannot be shrunk once created.
Does ext4 protect against silent data corruption?
No. While ext4 uses checksums to protect its own journal and metadata, it does not calculate checksums for user file data. Applications or storage layers above it must handle end-to-end data integrity verification.