Linux File Systems: ext4, XFS, Btrfs - Which to Choose?

Choosing the right filesystem for your Linux server is one of the most critical decisions you'll make as a system administrator. The filesystem determines how your data is stored, organized, and accessed, directly impacting performance, reliability, and scalability of your infrastructure.

This comprehensive guide explores the three most popular Linux filesystems—ext4, XFS, and Btrfs—helping you make an informed decision based on your specific use case, workload requirements, and operational needs.

Introduction to Linux Filesystems

A filesystem is the underlying structure that controls how data is stored and retrieved from storage devices. Modern Linux filesystems offer various features including journaling, compression, snapshots, and advanced data integrity mechanisms.

Understanding the strengths and weaknesses of each filesystem allows you to optimize storage performance and reliability for different scenarios:

  • Database servers require different filesystem characteristics than file servers
  • High-performance computing environments have unique requirements
  • Container orchestration platforms benefit from specific filesystem features
  • General-purpose servers need balanced performance and stability

This guide provides detailed comparisons, performance benchmarks, use case recommendations, and step-by-step implementation instructions for ext4, XFS, and Btrfs.

Prerequisites

Before working with filesystems, ensure you have:

  • Root or sudo privileges on your Linux system
  • Basic understanding of disk partitioning concepts
  • Familiarity with Linux command-line operations
  • Complete backup of all important data before making filesystem changes
  • Understanding of your workload characteristics (I/O patterns, file sizes, etc.)

Critical Data Safety Warning

WARNING: Creating or converting filesystems will destroy all existing data on the target partition. Always:

  1. Verify you're working on the correct device
  2. Create complete backups before proceeding
  3. Test filesystem configurations in non-production environments
  4. Document your filesystem choices and configurations
  5. Have a recovery plan in case of issues

ext4: The Reliable Standard

ext4 (Fourth Extended Filesystem) is the default filesystem on most Linux distributions and has been the standard for over a decade. It's the successor to ext3 and offers excellent reliability, performance, and maturity.

ext4 Key Features

  • Journaling: Metadata journaling protects against corruption from unexpected shutdowns
  • Extent-based allocation: Improves performance for large files
  • Delayed allocation: Optimizes write performance and reduces fragmentation
  • Large file support: Files up to 16TB, volumes up to 1EB
  • Fast fsck: Unallocated block groups are skipped during filesystem checks
  • Online defragmentation: Defragment without unmounting
  • Backward compatibility: Can mount as ext3 or ext2

ext4 Advantages

  1. Maturity and stability: Over 15 years of production use
  2. Excellent compatibility: Supported by all Linux distributions
  3. Well-tested and documented: Extensive community knowledge
  4. Good general-purpose performance: Balanced for most workloads
  5. Low CPU overhead: Minimal system resource requirements
  6. Reliable recovery tools: Mature e2fsck tool

ext4 Disadvantages

  1. No built-in snapshots: Requires LVM or external tools
  2. No data checksumming: Cannot detect silent data corruption
  3. Limited scalability: Not optimal for multi-petabyte storage
  4. No compression: Cannot save space with built-in compression
  5. No copy-on-write: Less efficient for certain workloads

ext4 Best Use Cases

  • General-purpose servers: Web servers, application servers
  • Boot partitions: Excellent stability and compatibility
  • Small to medium databases: MySQL, PostgreSQL on moderate loads
  • Development environments: Reliable and well-supported
  • Legacy application compatibility: Maximum compatibility guarantee

Creating ext4 Filesystem

Basic ext4 Creation

sudo mkfs.ext4 /dev/sdb1

ext4 with Custom Options

sudo mkfs.ext4 -L webserver_data -m 1 -E lazy_itable_init=0,lazy_journal_init=0 /dev/sdb1

Options explained:

  • -L: Set filesystem label
  • -m 1: Reserve only 1% for root (default 5%)
  • -E lazy_itable_init=0: Initialize tables immediately
  • -E lazy_journal_init=0: Initialize journal immediately

ext4 with SSD Optimization

sudo mkfs.ext4 -L ssd_partition -E nodiscard /dev/sdb1

Mounting ext4 with Optimal Options

sudo mount -o defaults,noatime,errors=remount-ro /dev/sdb1 /mnt/data

Mount options:

  • noatime: Don't update access times (improves performance)
  • errors=remount-ro: Remount read-only on errors
  • discard: Enable TRIM for SSDs (if supported)

Permanent ext4 Mount in /etc/fstab

UUID=xxx-xxx-xxx  /mnt/data  ext4  defaults,noatime,errors=remount-ro  0  2

ext4 Tuning and Optimization

View Current ext4 Settings

sudo tune2fs -l /dev/sdb1

Disable Access Time Updates

sudo tune2fs -o noatime /dev/sdb1

Set Filesystem Check Interval

# Check every 90 days
sudo tune2fs -i 90d /dev/sdb1

# Check after 30 mounts
sudo tune2fs -c 30 /dev/sdb1

Adjust Reserved Block Percentage

# Reserve only 1% for root (good for data partitions)
sudo tune2fs -m 1 /dev/sdb1

Enable Directory Indexing

sudo tune2fs -O dir_index /dev/sdb1

XFS: The High-Performance Choice

XFS is a high-performance journaling filesystem originally developed by Silicon Graphics. It excels at handling large files and high-throughput workloads, making it popular for media servers, databases, and enterprise applications.

XFS Key Features

  • Allocation groups: Parallel I/O operations for scalability
  • Delayed allocation: Optimizes write performance
  • Dynamic inode allocation: No inode limits
  • Online defragmentation: Defragment while mounted
  • Large filesystem support: Up to 8EB filesystem size
  • Guaranteed rate I/O: Quality of service for specific applications
  • Online growth: Expand filesystem while mounted

XFS Advantages

  1. Excellent large file performance: Optimized for files > 100MB
  2. Superior parallel I/O: Multiple threads can write simultaneously
  3. Scalability: Excellent for multi-TB and PB storage systems
  4. Online expansion: Grow filesystem without downtime
  5. No inode limitations: Creates inodes as needed
  6. Fast metadata operations: Efficient for large directories
  7. Robust enterprise features: Used by major cloud providers

XFS Disadvantages

  1. Cannot shrink: Can only grow, never shrink
  2. Higher memory usage: Requires more RAM than ext4
  3. Poor performance with small files: Not optimal for millions of tiny files
  4. Slower fsck: Filesystem check can take considerable time
  5. No built-in snapshots: Requires LVM integration
  6. Limited recovery tools: Fewer recovery options than ext4

XFS Best Use Cases

  • Large file storage: Video servers, backup servers, media storage
  • Database servers: MySQL, PostgreSQL with large datasets
  • Virtual machine storage: KVM, Xen, VMware datastores
  • Big data processing: Hadoop, data analytics platforms
  • High-throughput applications: Log processing, stream processing
  • NFS servers: Excellent for network file sharing

Creating XFS Filesystem

Basic XFS Creation

sudo mkfs.xfs /dev/sdb1

XFS with Custom Options

sudo mkfs.xfs -f -L backup_storage -d agcount=4 /dev/sdb1

Options explained:

  • -f: Force creation (overwrite existing filesystem)
  • -L: Set filesystem label
  • -d agcount=4: Set number of allocation groups

XFS with SSD Optimization

sudo mkfs.xfs -f -d sunit=512,swidth=512 /dev/sdb1

Mounting XFS with Optimal Options

sudo mount -o defaults,noatime,nodiratime,logbufs=8 /dev/sdb1 /mnt/data

Mount options:

  • noatime: Don't update access times
  • nodiratime: Don't update directory access times
  • logbufs=8: Increase log buffers (improves performance)
  • logbsize=256k: Increase log buffer size

Permanent XFS Mount in /etc/fstab

UUID=xxx-xxx-xxx  /mnt/data  xfs  defaults,noatime,nodiratime,logbufs=8  0  2

XFS Tuning and Optimization

View XFS Filesystem Information

sudo xfs_info /dev/sdb1

Check XFS Filesystem

# Unmount first
sudo umount /dev/sdb1

# Run filesystem check
sudo xfs_repair /dev/sdb1

Defragment XFS Filesystem

# Check fragmentation
sudo xfs_db -c frag -r /dev/sdb1

# Defragment entire filesystem
sudo xfs_fsr /mnt/data

# Defragment specific file
sudo xfs_fsr /mnt/data/large_file.dat

Expand XFS Filesystem

# After expanding partition
sudo xfs_growfs /mnt/data

Set XFS Project Quotas

# Enable project quotas
sudo mount -o remount,prjquota /mnt/data

# Create project
sudo xfs_quota -x -c 'project -s -p /mnt/data/project1 100' /mnt/data
sudo xfs_quota -x -c 'limit -p bhard=10g 100' /mnt/data

Btrfs: The Advanced Modern Filesystem

Btrfs (B-tree filesystem) is a modern copy-on-write filesystem with advanced features like snapshots, compression, and built-in RAID. While relatively newer, it's increasingly adopted for its powerful capabilities.

Btrfs Key Features

  • Copy-on-write: Never overwrites data in place
  • Built-in snapshots: Instant, space-efficient snapshots
  • Online compression: Transparent data compression (zlib, lzo, zstd)
  • Checksumming: Detects data corruption
  • Built-in RAID: Software RAID 0, 1, 10, 5, 6
  • Online defragmentation and balancing: Optimize without downtime
  • Subvolumes: Flexible internal partitioning
  • Send/receive: Efficient incremental backups

Btrfs Advantages

  1. Snapshots: Instant, space-efficient snapshots
  2. Data integrity: Checksums detect silent corruption
  3. Compression: Save disk space automatically
  4. Flexible space management: Dynamic resizing
  5. Advanced features: Deduplication, self-healing (with RAID)
  6. Subvolumes: Logical partitioning without physical partitions
  7. Incremental backups: Efficient send/receive mechanism
  8. Online filesystem operations: Most operations work while mounted

Btrfs Disadvantages

  1. Less mature: Newer than ext4 and XFS
  2. RAID 5/6 stability concerns: Not recommended for production
  3. Higher CPU usage: Checksumming and compression overhead
  4. More complex: Steeper learning curve
  5. Memory intensive: Requires more RAM for metadata
  6. Variable performance: Performance can be unpredictable
  7. Fragmentation: Can suffer from fragmentation over time

Btrfs Best Use Cases

  • Desktop systems: Snapshots protect against system updates
  • Container hosts: Docker, Kubernetes with snapshot capabilities
  • Development environments: Snapshots for experimentation
  • Backup servers: Incremental send/receive backups
  • Home servers: Advanced features for power users
  • Systems requiring rollback: Quick system recovery
  • Space-constrained systems: Compression saves space

Creating Btrfs Filesystem

Basic Btrfs Creation

sudo mkfs.btrfs /dev/sdb1

Btrfs with Label and Compression

sudo mkfs.btrfs -f -L container_storage /dev/sdb1

Btrfs RAID Configuration

Multiple device RAID:

# RAID 1 (mirroring)
sudo mkfs.btrfs -f -d raid1 -m raid1 /dev/sdb1 /dev/sdc1

# RAID 0 (striping)
sudo mkfs.btrfs -f -d raid0 -m raid0 /dev/sdb1 /dev/sdc1

Mounting Btrfs with Compression

sudo mount -o compress=zstd,noatime /dev/sdb1 /mnt/data

Compression options:

  • compress=zlib: Better compression, slower
  • compress=lzo: Faster, less compression
  • compress=zstd: Best balance (recommended)
  • compress-force=zstd: Force compression on all files

Permanent Btrfs Mount in /etc/fstab

UUID=xxx-xxx-xxx  /mnt/data  btrfs  defaults,compress=zstd,noatime  0  0

Btrfs Subvolumes and Snapshots

Create Subvolume

sudo btrfs subvolume create /mnt/data/subvol1

List Subvolumes

sudo btrfs subvolume list /mnt/data

Create Snapshot

# Read-write snapshot
sudo btrfs subvolume snapshot /mnt/data/subvol1 /mnt/data/subvol1_snapshot

# Read-only snapshot
sudo btrfs subvolume snapshot -r /mnt/data/subvol1 /mnt/data/subvol1_snapshot_ro

Delete Subvolume or Snapshot

sudo btrfs subvolume delete /mnt/data/subvol1_snapshot

Rollback from Snapshot

# Rename current subvolume
sudo mv /mnt/data/subvol1 /mnt/data/subvol1_broken

# Restore from snapshot
sudo btrfs subvolume snapshot /mnt/data/subvol1_snapshot /mnt/data/subvol1

Btrfs Maintenance and Optimization

Check Filesystem Usage

sudo btrfs filesystem usage /mnt/data
sudo btrfs filesystem df /mnt/data

Balance Filesystem

# Full balance (time-consuming)
sudo btrfs balance start /mnt/data

# Balance data only
sudo btrfs balance start -dusage=50 /mnt/data

# Balance metadata
sudo btrfs balance start -musage=50 /mnt/data

Defragment Btrfs

# Defragment entire filesystem
sudo btrfs filesystem defragment -r /mnt/data

# Defragment specific file
sudo btrfs filesystem defragment /mnt/data/large_file.dat

# Defragment with compression
sudo btrfs filesystem defragment -r -czstd /mnt/data

Scrub for Data Integrity

# Start scrub
sudo btrfs scrub start /mnt/data

# Check scrub status
sudo btrfs scrub status /mnt/data

# Cancel scrub
sudo btrfs scrub cancel /mnt/data

Resize Btrfs Filesystem

# Grow to maximum size
sudo btrfs filesystem resize max /mnt/data

# Grow by specific amount
sudo btrfs filesystem resize +10G /mnt/data

# Shrink (be careful!)
sudo btrfs filesystem resize -5G /mnt/data

Send/Receive for Backups

# Create read-only snapshot
sudo btrfs subvolume snapshot -r /mnt/data/subvol1 /mnt/data/snap1

# Send to backup location
sudo btrfs send /mnt/data/snap1 | sudo btrfs receive /mnt/backup/

# Incremental backup
sudo btrfs subvolume snapshot -r /mnt/data/subvol1 /mnt/data/snap2
sudo btrfs send -p /mnt/data/snap1 /mnt/data/snap2 | sudo btrfs receive /mnt/backup/

Performance Comparison

Sequential Read/Write Performance

Large files (1GB+):

  • XFS: Excellent (fastest)
  • ext4: Good
  • Btrfs: Good (with proper tuning)

Small files (<1MB):

  • ext4: Excellent
  • XFS: Good
  • Btrfs: Good

Random I/O Performance

Database workloads:

  • ext4: Excellent (low latency)
  • XFS: Very good (high throughput)
  • Btrfs: Good (variable depending on COW overhead)

Metadata Operations

Creating/deleting many files:

  • ext4: Very good
  • XFS: Excellent
  • Btrfs: Good (slower due to checksumming)

CPU and Memory Usage

CPU overhead:

  • ext4: Lowest
  • XFS: Low to moderate
  • Btrfs: Moderate to high (with compression/checksumming)

Memory requirements:

  • ext4: Low
  • XFS: Moderate
  • Btrfs: Higher (metadata caching)

Filesystem Comparison Table

Featureext4XFSBtrfs
MaturityVery highHighModerate
Maximum file size16 TB8 EB16 EB
Maximum filesystem size1 EB8 EB16 EB
SnapshotsNoNoYes (built-in)
CompressionNoNoYes (zlib, lzo, zstd)
ChecksummingNoNoYes
Online resizeGrow onlyGrow onlyGrow and shrink
RAID supportNoNoYes (built-in)
DefragmentationYesYesYes
Copy-on-writeNoNoYes
JournalingMetadataMetadataCOW (no journal)
Best for large filesGoodExcellentGood
Best for small filesExcellentGoodGood
CPU overheadLowLow-ModerateModerate-High
Recovery toolsExcellentGoodGood
Learning curveEasyModerateComplex

Decision Matrix: Which Filesystem Should You Choose?

Choose ext4 if:

  • You need maximum stability and reliability
  • Running general-purpose servers (web, application)
  • Want lowest CPU overhead and resource usage
  • Need excellent small file performance
  • Require broad compatibility
  • Running older kernels (pre-3.10)
  • New to Linux system administration
  • Need proven, battle-tested filesystem

Example scenarios:

  • Corporate web servers
  • Application servers
  • Boot and system partitions
  • Small to medium databases
  • Development environments
  • Hosting panel servers (cPanel, Plesk)

Choose XFS if:

  • Working with large files (100MB+)
  • Running high-performance databases
  • Need parallel I/O capabilities
  • Managing multi-TB storage systems
  • Running VM datastores
  • Need online filesystem expansion
  • Have consistent large file operations
  • Require enterprise-grade performance

Example scenarios:

  • Video editing servers
  • Large database servers (PostgreSQL, MySQL)
  • Virtual machine storage
  • Backup servers with large files
  • Media streaming servers
  • Big data analytics platforms
  • Log aggregation systems

Choose Btrfs if:

  • Need snapshot capabilities
  • Want built-in compression
  • Require data integrity verification
  • Managing container environments
  • Need flexible subvolume management
  • Want incremental backup capability
  • Have adequate system resources
  • Willing to manage more complexity

Example scenarios:

  • Docker/Kubernetes hosts
  • Development workstations
  • Systems requiring frequent snapshots
  • Backup servers with deduplication
  • Home/lab servers
  • Systems with limited disk space (compression helps)
  • Environments requiring easy rollback

Migration Between Filesystems

Migration Strategy

WARNING: Migration requires backup and data copy. Plan for downtime.

General Migration Steps

  1. Backup all data
  2. Create new partition with target filesystem
  3. Copy data to new filesystem
  4. Verify data integrity
  5. Update /etc/fstab
  6. Test and verify
  7. Remove old partition

Migrating from ext4 to XFS

# 1. Backup data
sudo rsync -avxHAX /mnt/old_ext4/ /backup/

# 2. Unmount old filesystem
sudo umount /mnt/old_ext4

# 3. Create XFS filesystem
sudo mkfs.xfs -f /dev/sdb1

# 4. Mount new filesystem
sudo mount /dev/sdb1 /mnt/new_xfs

# 5. Restore data
sudo rsync -avxHAX /backup/ /mnt/new_xfs/

# 6. Update /etc/fstab
sudo nano /etc/fstab
# Change filesystem type from ext4 to xfs

Migrating from ext4 to Btrfs

# In-place conversion (risky, backup first!)
sudo btrfs-convert /dev/sdb1

# Or manual migration
sudo mkfs.btrfs -f /dev/sdb1
sudo mount /dev/sdb1 /mnt/new_btrfs
sudo rsync -avxHAX /backup/ /mnt/new_btrfs/

Verification and Testing

Verify Filesystem Type

df -T
lsblk -f
sudo blkid /dev/sdb1

Test Filesystem Performance

Simple Write Test

sudo dd if=/dev/zero of=/mnt/data/testfile bs=1G count=1 oflag=direct

Simple Read Test

sudo dd if=/mnt/data/testfile of=/dev/null bs=1M

Comprehensive Benchmark with fio

# Install fio
sudo apt install fio   # Debian/Ubuntu
sudo yum install fio   # CentOS/RHEL

# Random read/write test
sudo fio --name=random-rw --ioengine=libaio --iodepth=32 --rw=randrw \
  --rwmixread=70 --bs=4k --direct=1 --size=1G --numjobs=4 \
  --runtime=60 --group_reporting --directory=/mnt/data

Check Filesystem Health

ext4 Filesystem Check

# Unmount first
sudo umount /dev/sdb1

# Check filesystem
sudo e2fsck -f -v /dev/sdb1

XFS Filesystem Check

# Unmount first
sudo umount /dev/sdb1

# Check and repair
sudo xfs_repair -v /dev/sdb1

Btrfs Filesystem Check

# Check while mounted
sudo btrfs scrub start /mnt/data
sudo btrfs scrub status /mnt/data

# Check while unmounted
sudo umount /dev/sdb1
sudo btrfs check /dev/sdb1

Troubleshooting Common Issues

Issue: Filesystem Full but df Shows Space Available

Cause: Inode exhaustion (ext4) or metadata issues

Solution for ext4:

# Check inode usage
df -i

# If inodes exhausted, need to delete files or recreate filesystem with more inodes
sudo mkfs.ext4 -N 10000000 /dev/sdb1

Solution for XFS:

XFS creates inodes dynamically, but may have space issues:

# Check space usage
sudo xfs_db -c "freesp -s" -r /dev/sdb1

# May need filesystem balance

Solution for Btrfs:

# Balance filesystem
sudo btrfs balance start -dusage=50 /mnt/data

# Check metadata
sudo btrfs filesystem usage /mnt/data

Issue: Poor Performance After Heavy Use

Solution for ext4:

# Defragment
sudo e4defrag /mnt/data

Solution for XFS:

# Defragment
sudo xfs_fsr /mnt/data

Solution for Btrfs:

# Defragment and balance
sudo btrfs filesystem defragment -r /mnt/data
sudo btrfs balance start /mnt/data

Issue: Filesystem Corruption Detected

Solution for ext4:

sudo umount /dev/sdb1
sudo e2fsck -f -y /dev/sdb1

Solution for XFS:

sudo umount /dev/sdb1
sudo xfs_repair /dev/sdb1

Solution for Btrfs:

sudo umount /dev/sdb1
sudo btrfs check --repair /dev/sdb1

Issue: Btrfs Balance Taking Too Long

Solution:

# Cancel current balance
sudo btrfs balance cancel /mnt/data

# Run filtered balance
sudo btrfs balance start -dusage=50 -musage=50 /mnt/data

Issue: Cannot Mount After Kernel Upgrade

Solution:

Ensure filesystem support is enabled:

# Check loaded modules
lsmod | grep -E 'ext4|xfs|btrfs'

# Load module if needed
sudo modprobe ext4
sudo modprobe xfs
sudo modprobe btrfs

Best Practices

1. Match Filesystem to Workload

Don't use one-size-fits-all approach:

  • Analyze I/O patterns
  • Consider file sizes
  • Evaluate feature requirements
  • Test performance in similar environment

2. Use Appropriate Mount Options

Optimize mount options for use case:

# Web server (many small files)
defaults,noatime,errors=remount-ro

# Database server (large files, sync important)
defaults,noatime,data=ordered

# Media server (large sequential I/O)
defaults,noatime,nodiratime,logbufs=8

3. Regular Maintenance

Schedule regular filesystem maintenance:

# Create weekly maintenance script
sudo nano /etc/cron.weekly/filesystem-maintenance

#!/bin/bash
# For XFS
xfs_fsr /mnt/xfs_data

# For Btrfs
btrfs filesystem defragment -r /mnt/btrfs_data
btrfs balance start -dusage=50 /mnt/btrfs_data

4. Monitor Filesystem Health

Implement proactive monitoring:

# Monitor disk space
df -h

# Monitor inode usage
df -i

# Check SMART status
sudo smartctl -a /dev/sdb

# Btrfs scrub regularly
sudo btrfs scrub start /mnt/data

5. Plan for Growth

Consider future capacity needs:

  • Leave room for filesystem expansion
  • Use LVM for flexibility
  • Monitor growth trends
  • Plan migration strategies

6. Document Configuration

Maintain documentation:

  • Filesystem type and reasons
  • Mount options and their purposes
  • Maintenance schedules
  • Performance baselines

7. Test Disaster Recovery

Regularly test recovery procedures:

  • Practice filesystem checks
  • Test backup restoration
  • Verify snapshot functionality (Btrfs)
  • Document recovery procedures

8. Keep Systems Updated

Maintain current software:

  • Update kernel for filesystem improvements
  • Install filesystem utilities updates
  • Review release notes for bug fixes
  • Test updates in non-production first

Advanced Considerations

Combining Filesystems with LVM

Use LVM for flexibility:

# Create physical volume
sudo pvcreate /dev/sdb1

# Create volume group
sudo vgcreate vg_data /dev/sdb1

# Create logical volumes with different filesystems
sudo lvcreate -L 100G -n lv_ext4 vg_data
sudo lvcreate -L 200G -n lv_xfs vg_data
sudo lvcreate -L 300G -n lv_btrfs vg_data

# Format with different filesystems
sudo mkfs.ext4 /dev/vg_data/lv_ext4
sudo mkfs.xfs /dev/vg_data/lv_xfs
sudo mkfs.btrfs /dev/vg_data/lv_btrfs

Filesystem Layering

Consider filesystem layering for advanced features:

# LVM for flexibility
# + LUKS for encryption
# + Filesystem for features

# Example: Encrypted XFS on LVM
sudo pvcreate /dev/sdb1
sudo vgcreate vg_secure /dev/sdb1
sudo lvcreate -L 500G -n lv_encrypted vg_secure
sudo cryptsetup luksFormat /dev/vg_secure/lv_encrypted
sudo cryptsetup open /dev/vg_secure/lv_encrypted encrypted_data
sudo mkfs.xfs /dev/mapper/encrypted_data

Container-Optimized Configurations

For Docker/Kubernetes:

# Btrfs for Docker
sudo mkfs.btrfs /dev/sdb1
sudo mount /dev/sdb1 /var/lib/docker
# Configure Docker to use btrfs driver

# Or XFS with overlay2
sudo mkfs.xfs /dev/sdb1
sudo mount -o noatime,nodiratime /dev/sdb1 /var/lib/docker
# Docker will use overlay2 by default

Conclusion

Choosing the right filesystem is crucial for optimal Linux server performance and reliability. Each filesystem—ext4, XFS, and Btrfs—offers distinct advantages for specific use cases.

Quick Decision Guide:

  • Default choice: ext4 (stability, compatibility, general purpose)
  • Large files, high performance: XFS (databases, media, VMs)
  • Advanced features, snapshots: Btrfs (containers, development, backups)

Key takeaways:

  1. Understand your workload before choosing a filesystem
  2. ext4 remains the safest choice for general-purpose use
  3. XFS excels at large files and high-throughput scenarios
  4. Btrfs provides advanced features but requires more management
  5. Test performance in your specific environment
  6. Regular maintenance ensures long-term performance
  7. Keep backups regardless of filesystem choice
  8. Document your decisions for future reference

Remember that no single filesystem is perfect for all scenarios. Analyze your specific requirements, test thoroughly, and choose the filesystem that best aligns with your workload characteristics, operational needs, and team expertise.

By understanding the strengths and limitations of ext4, XFS, and Btrfs, you can make informed decisions that optimize storage performance, reliability, and manageability for your Linux infrastructure.