Side by Side
| ext4 | XFS | |
|---|---|---|
| Default on | Debian, Ubuntu | AlmaLinux, Rocky Linux |
| Grow | Online | Online |
| Shrink | Offline only | Not in practice |
| Grow tool | resize2fs | xfs_growfs |
| Repair tool | e2fsck | xfs_repair |
| Inodes | Set at creation | Created as needed |
| Boot check | Pass 1 or 2 | Pass 0 |
| Tools package | e2fsprogs | xfsprogs |
Both keep a journal, so after a sudden power loss the file system's structure is recovered from the journal at the next mount, though data still in memory can be lost.
Growing and Shrinking
Both grow while mounted, which covers the common case of a disk upgrade; see how to grow a partition after a disk upgrade. Only ext4 can be made smaller, and only while unmounted. XFS cannot be shrunk in practice (xfs_growfs can only trim its last allocation group): to make an XFS volume smaller, you copy the data off, create a new, smaller file system, and copy it back. If you plan to move space between LVM volumes, ext4 leaves that door open.
Performance in General Terms
XFS divides a file system into allocation groups that can be written in parallel, which suits large files, many parallel writers, and very large volumes. ext4 is a strong all-rounder for everyday server work. On a typical virtual server, the disk, the cache, and the application decide performance far more than the choice between these two. If performance matters for your workload, test both with your own data rather than relying on published benchmarks.
Many Small Files
ext4 sets the number of inodes when the file system is created. Millions of tiny files, such as cache or session files, can use every inode while space remains, and new files then fail; see no space left on device. You can create ext4 with more inodes using mkfs.ext4 -i (fewer bytes per inode) or -N (a total count); the ratio cannot be changed later. XFS creates inodes as files need them, up to a share of the space set when it is created, so it rarely runs into this limit.
Checks and Repairs
- ext4:
e2fsck, run through fsck, and a check at boot when the pass field asks for it. - XFS:
xfs_repair;fsck.xfsdoes nothing in a normal boot; XFS replays its journal when mounted. - Both: repair only an unmounted file system. See how to check and repair a file system with fsck.
Which One Fits?
- Keep the distribution default for the system disk. It is what the installer, the documentation, and most guides for that system assume.
- Choose ext4 for small to medium data disks, for volumes you may need to shrink, and when you want the same file system across Debian, Ubuntu, and other systems.
- Choose XFS for large data volumes, large files such as media or backups, and workloads with many parallel writers.
Btrfs and ZFS in Brief
Btrfs and ZFS go further: they checksum data, take snapshots inside the file system, compress, and manage several disks themselves. Btrfs is part of the Linux kernel, but whether a distribution supports it on servers differs, so check yours first. ZFS is developed outside the main kernel for licensing reasons; Ubuntu ships its tools as a package. Both reward planning and add concepts to learn; for a plain data disk, ext4 or XFS is the simpler choice.
Switching Later
There is no in-place conversion between ext4 and XFS. Back up, create the new file system as in how to format a disk in Linux, and restore. Check the backup before you format, because formatting has no undo.