XFS: High-Performance Filesystem

8 min

Explore XFS - the high-performance 64-bit journaling filesystem optimized for large files and parallel I/O. Learn why it excels at handling massive data workloads.

Best viewed on desktop for optimal interactive experience

What is XFS?

XFS is a high-performance 64-bit journaling filesystem created by Silicon Graphics (SGI) in 1993 for their IRIX operating system. Ported to Linux in 2001, XFS excels at parallel I/O operations and handling large files, making it the default filesystem for Red Hat Enterprise Linux.

Think of XFS as the Formula 1 car of filesystems - built for speed, especially when dealing with large files and multiple concurrent operations.

Key Design Goals

XFS was designed with specific objectives:

  1. Extreme scalability - Support massive files and filesystems
  2. High performance - Maximize throughput for large operations
  3. Efficient space usage - Minimize fragmentation
  4. Parallel operations - Scale with multiple CPUs/cores

Architecture

Allocation Groups (AGs): Filesystem divided into independent regions for parallel operations. Reduces lock contention, scales with CPUs.

B+trees everywhere: Free space, inodes, directories, extent maps all use B+trees for efficient metadata management.

How XFS Works: Interactive Exploration

See XFS's key features in action - parallel I/O across allocation groups, extent-based allocation, and delayed allocation:

XFS in Action: Parallel I/O Across Allocation Groups

Watch how XFS achieves high performance through allocation groups, extents, and delayed allocation

Step 1 of 520%
AG 0
Used: 30%
AG 1
Used: 45%
AG 2
Used: 20%
AG 3
Used: 55%

Initial State: 4 Allocation Groups

XFS divides filesystem into independent AGs. Each AG can be accessed in parallel.

Each AG is 256GB (1TB filesystem ÷ 4)

Independent free space B+trees per AG

Separate inode B+trees per AG

Per-AG locks minimize contention

Scales with CPU cores

1 / 5

Creating and Managing XFS

Creating XFS Filesystem

# Basic creation sudo mkfs.xfs /dev/sdb1 # With options sudo mkfs.xfs -L "DataDrive" \ -b size=4096 \ # Block size -m crc=1,finobt=1 \ # Metadata checksums, free inode btree /dev/sdb1 # For RAID arrays (stripe-aligned) sudo mkfs.xfs -d su=64k,sw=4 /dev/md0 # 64KB stripe unit, 4 stripes # For SSDs sudo mkfs.xfs -m crc=1,finobt=1 -d discardblocks=1 /dev/nvme0n1 # Large filesystem optimizations sudo mkfs.xfs -d agcount=32 /dev/sdb # More AGs for parallelism

Mount Options

# Performance sudo mount -o noatime,inode64,allocsize=16m /dev/sdb1 /mnt # Databases sudo mount -o noatime,largeio,swalloc /dev/sdb1 /mnt/db # SSD sudo mount -o noatime,discard /dev/sdb1 /mnt/ssd

Key Features

Extent-based: Contiguous blocks reduce metadata (1 extent entry vs 1001 block entries for 4MB file)

Delayed allocation: Reserves space, allocates on flush → better contiguity

Direct I/O: Bypass page cache for databases (requires aligned buffers)

Performance

Parallel I/O: Multiple allocation groups enable concurrent operations with per-AG locks.

Preallocation: Reserve contiguous space with fallocate → prevents fragmentation.

Real-time subvolume: Separate device for guaranteed bandwidth (streaming media).

XFS Tools and Utilities

# Filesystem info sudo xfs_info /mnt # Grow filesystem (can't shrink!) sudo xfs_growfs /mnt # Repair (unmounted) sudo xfs_repair /dev/sdb1 # Defragment sudo xfs_fsr /mnt # Freeze for snapshots sudo xfs_freeze -f /mnt sudo lvcreate -s -n snapshot -L 10G /dev/vg/lv sudo xfs_freeze -u /mnt # Check fragmentation sudo xfs_db -c frag -r /dev/sdb1

Performance Tuning

# Large files (media servers) mount -o allocsize=1g,largeio /dev/sdb1 /mnt/media xfs_io -c "extsize 1g" /mnt/media/video.mp4 # Databases mkfs.xfs -d agcount=16 /dev/sdb1 mount -o noatime,nobarrier,logbufs=8 /dev/sdb1 /mnt/db # Many small files mkfs.xfs -d agcount=64 -m finobt=1 /dev/sdb1 mount -o noatime,inode64 /dev/sdb1 /mnt

XFS Quotas

Project quotas: Unique to XFS - per-directory tree limits

# Enable and configure mount -o prjquota /dev/sdb1 /mnt echo "10:/mnt/project1" >> /etc/projects xfs_quota -x -c "limit -p bsoft=5g bhard=10g project1" /mnt # User/group quotas mount -o usrquota,grpquota /dev/sdb1 /mnt xfs_quota -x -c "limit -u bsoft=5g bhard=10g alice" /mnt xfs_quota -c "report -h" /mnt

Backup and Recovery

# XFS native backup tools sudo xfsdump -f /backup/full.dump -L "Full Backup" /mnt sudo xfsrestore -f /backup/full.dump /mnt/restore # Metadata backup (analysis only) xfs_metadump /dev/sdb1 metadata.dump

Troubleshooting

# "No space left" with free space df -i /mnt # Check inodes lsof +L1 /mnt # Deleted but open files # Mount fails after crash mount -o ro,norecovery /dev/sdb1 /mnt xfs_repair -L /dev/sdb1 # Zero corrupted log # Poor performance xfs_db -c frag -r /dev/sdb1 # Check fragmentation xfs_fsr -v /mnt # Defragment

XFS vs Other Filesystems

Performance Comparison

# Performance Comparison: # # Large Sequential Writes: # XFS ████████████████████ 100% # ext4 ███████████████████ 95% # Btrfs ████████████████ 80% # ZFS ███████████████ 75% # # Parallel I/O: # XFS ████████████████████ 100% # ext4 ████████████████ 80% # Btrfs ███████████████ 75% # ZFS ██████████████ 70% # # Metadata Operations: # ext4 ████████████████████ 100% # XFS ██████████████████ 90% # Btrfs ████████████████ 80% # ZFS ███████████████ 75%

Feature Comparison

FeatureXFSext4BtrfsZFS
Max file size8 EiB16 TiB16 EiB16 EiB
Max volume8 EiB1 EiB16 EiB256 ZiB
Snapshots
Compression
ChecksumsMetadata only
Shrinking
Performance█████████████

Best Practices

# Filesystem creation mkfs.xfs -m crc=1,finobt=1 /dev/sdb1 # General use mkfs.xfs -d agcount=32 /dev/sdb1 # Many small files # Regular maintenance (cron) 0 2 * * 0 xfs_db -c frag -r /dev/sdb1 # Weekly frag check 0 3 1 * * xfs_fsr /mnt # Monthly defrag # Monitor space and errors df -h /mnt && dmesg | grep -i xfs | tail

When to Use XFS

✅ Perfect for:

  • Media servers - Large file streaming
  • Scientific computing - Parallel I/O workloads
  • Databases - With proper tuning
  • Virtual machine storage - Good performance
  • RHEL/CentOS systems - Default and well-supported
  • High-performance computing - Scales with hardware

❌ Consider alternatives for:

  • Root filesystem on desktop - ext4 simpler
  • Need snapshots - Use Btrfs or ZFS
  • Need compression - Use Btrfs or ZFS
  • Small embedded systems - Too heavyweight
  • Need to shrink filesystem - Not supported

XFS Limitations

  1. Cannot shrink - Only grows, plan accordingly
  2. No snapshots - Use LVM or switch to Btrfs/ZFS
  3. No compression - Must handle at application level
  4. 32-bit limitations - Requires 64-bit kernel
  5. Recovery limitations - Less robust than ext4's fsck

Future Development

Ongoing Work

  • Reflink support - Copy-on-write file copies
  • Online repair - Fix filesystem while mounted
  • Reverse mapping - Better error reporting
  • Parent pointers - Improved directory operations
  • Y2038 fixes - Beyond 32-bit timestamps

Migration from ext4

# No in-place conversion - must copy mkfs.xfs /dev/sdc1 mount /dev/sdb1 /mnt/ext4 && mount /dev/sdc1 /mnt/xfs # Use xfsdump/restore or rsync rsync -avxHAX --progress /mnt/ext4/ /mnt/xfs/

Conclusion

XFS represents the pinnacle of traditional filesystem performance. While it lacks modern features like snapshots and compression, it excels at what it does: handling large files and parallel I/O with exceptional speed and reliability.

For workloads involving large files, streaming media, or parallel operations, XFS is often unmatched. Its maturity, stability, and integration with enterprise Linux distributions make it a safe choice for production systems.

The trade-off is clear: maximum performance and scalability for traditional filesystem operations, but without the advanced features of newer CoW filesystems. For many workloads, especially in enterprise environments, this trade-off is exactly right.

← Back to Filesystems Overview | Compare with ext4 →

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

Mastodon