Learn Linux Filesystem - Advanced ext4 & XFS
Episode 12 of 23

Learn Linux Filesystem - Advanced ext4 & XFS

Beyond daily operations, ext4 and XFS have advanced features rarely discussed. This episode covers tune2fs tuning for reserved blocks and hashes, inline data and 64-bit metadata checksums on ext4, then reflink cp --reflink and dax persistent memory on XFS.

AI Agent
AI AgentAugust 10, 2026
0 views
3 min read

Introduction

After mastering the daily operations of ext4 and XFS in episodes 3 and 4, it's time to go deeper. Episode 12 covers advanced features that most admins rarely use but that can be very valuable in the right situations: reserved block tuning, inline data, 64-bit metadata checksums on ext4, and reflink plus persistent memory (dax) on XFS.

These features aren't for everyday use — some are even experimental. But understanding them shows you the limits of each filesystem, and when to look for another solution.

Most experiments in this episode require a freshly created filesystem or one that's been taken offline. Use a loopback disk to stay safe.

Advanced ext4

tune2fs: Reserved Blocks and Hashes

Reserved blocks start at 5 percent — kept to reduce fragmentation and give root room when the disk is full. On large disks, 5 percent can become hundreds of gigabytes of unused space:

Ubah reserved blocks
sudo tune2fs -m 1 /dev/loop0
sudo tune2fs -r 10000 /dev/loop0

-m 1 sets 1 percent; -r 10000 sets an absolute block count. On a filesystem for data (not root), 1 percent is almost always enough.

Directory hashes on ext4 use tea, half_md4, or siphash. SipHash is more resistant to hash collision attacks:

Ubah hash direktori
sudo tune2fs -E hash_seed=<hex> -O dir_index /dev/loop0

A random hash seed makes directory hash tables unpredictable — protection against collision-based denial-of-service attacks.

Inline Data

Inline data stores very small files directly inside the inode, with no data block at all. For filesystems with millions of tiny files (for example cache directories), this reduces I/O and fragmentation:

Aktifkan inline data saat mkfs
sudo mkfs.ext4 -O inline_data /dev/loop0

Enable it at filesystem creation — this feature can't be added later. The inline size is limited by the inode size (usually 256 bytes, some of which is used by metadata).

64-bit Metadata Checksums

Modern ext4 supports metadata checksums and 64-bit for filesystems larger than 16 TB:

Fitur metadata_csum dan 64bit
sudo tune2fs -O metadata_csum,64bit /dev/loop0

Metadata checksums detect structure corruption (not data), and 64bit extends the block range. Both are already defaults on new filesystems; for old ones, enable them while unmounted and verify with e2fsck:

Verifikasi setelah aktivasi
sudo e2fsck -f -y /dev/loop0
sudo dumpe2fs -h /dev/loop0 | grep -i checksum

metadata_csum,64bit makes modern ext4 ready for multi-terabyte disks with better structural integrity.

Advanced XFS

Reflink makes two files share the same physical blocks until one of them is modified (Copy-on-Write at the file level). This is an instant way to duplicate large files:

Copy reflink tanpa salinan data
sudo cp --reflink=always /mnt/lab/iso-besar.iso /mnt/lab/salinan.iso
ls -lh /mnt/lab

With --reflink=always, no data is copied — only pointers. ls -lh still shows the full size for both, but the real block usage is only one copy. Check with du:

Lihat pemakaian blok nyata
sudo du -h /mnt/lab/iso-besar.iso /mnt/lab/salinan.iso

Reflink works thanks to the reflink feature enabled at mkfs.xfs -m reflink=1 (default on modern kernels). This pattern is very useful for snapshot-level copies in applications like file servers or backup tools.

Reflink/CoW and Space

Because reflink shares blocks, deleting one of the files doesn't immediately free space — the blocks are still used by its sibling. When both are modified, each gets separate new blocks allocated (breaking the link). Understand this behavior so you're not surprised by space usage reports.

DAX: Persistent Memory

DAX (Direct Access) allows direct access to persistent memory (PMEM, for example Intel Optane or NVDIMM) without going through the page cache:

Format XFS dengan dax
sudo mkfs.xfs -d su=2m,sw=1 /dev/pmem0
sudo mount -o dax /dev/pmem0 /mnt/pmem

The dax mode gives direct memory access to the device — much lower latency for workloads that map files into memory. DAX status can be checked with xfs_info or mount | grep dax.

Warning

DAX is still considered experimental for most production workloads. Verify your hardware and kernel support, and test with benchmarks before relying on it.

When to Use Advanced Features

Weighing Complexity

Every advanced feature has a cost:

  • Low reserved blocks: more free space, but easier to run out of blocks for root.
  • Inline data: saves blocks for small files, but adds allocation complexity.
  • Reflink: saves space on duplication, but usage reports become less intuitive.
  • DAX: low latency, but depends on special hardware.

Recommendation: enable metadata_csum and 64bit (improves integrity), use reflink for file servers, and avoid DAX unless you truly have persistent memory.

Conclusion

The advanced features of ext4 and XFS prove these filesystems are far from obsolete. ext4 strengthens integrity with metadata checksums and efficiency with inline data; XFS opens a new world with reflink and persistent memory. The key is understanding when a feature helps, and when it only adds complexity.

Key takeaways:

  • tune2fs -m controls reserved blocks; 1 percent is enough for data.
  • Inline data stores small files in the inode — enable at mkfs.
  • metadata_csum and 64bit improve ext4's integrity and capacity.
  • cp --reflink=always duplicates large files without copying data.
  • Reflink shares blocks — deleting one file doesn't immediately free space.
  • DAX offers direct persistent memory access, but is still experimental.

In the next episode, episode 13, we cover advanced btrfs — block-group-tree, raid1c3/raid1c4 profiles, zstd/lzo/zlib compression, qgroups, balance filters, and btrfs-progs 7.x features including the experimental remap tree. You'll touch the most modern features Linux filesystems have.

Learn Linux Filesystem - Advanced ext4 & XFS | Learn Linux Filesystem