Ext4 vs XFS – Which Filesystem Should You Use

Users running a  Linux system hardly pay attention to the underlying filesystem. In fact, during the installation of Linux, there’s a tendency to often go with the default filesystem listed without exploring other available options. For windows, things are a lot easier since NTFS is the dominant filesystem. With Linux, there are numerous filesystems at your disposal. These include the Ext4, XFS, ZFS, and BTRFS.

The most widely used filesystems are Ext4 and XFS, with the latter being the default filesystem in RHEL-based distros and Ext4 being the standard filesystem in Debian and Ubuntu distributions. When choosing a filesystem some of the factors that need to be considered include scalability, stability, and data integrity.

In this guide, we will focus on Ext4 and XFS filesystems and seek to understand the differences between these two.

The Ext4 filesystem

The Ext4 filesystem ( Extended filesystem) is the fourth generation of the Ext filesystem family whose origin can be traced back to the Minix operating system which was first introduced in 1987. The Ext filesystem is the first filesystem to underpin the Linux kernel when it was unveiled back in 1992. It came into the picture in 2008, with Linux 2.6.28. succeeding its predecessor, ext3.

Ext4 perfectly manages many small files and ensures metadata is correctly written even write cache loses power.

At a glance, its main features include:

  • Support for large file sizes - The Ext4 supports a single file size of up to 16 TiB ( Tebibytes ) whereas XFS supports a max file size of up to 8 exbibytes.
  • Delay allocation based on extent for faster file allocations.
  • Backward compatibility - Another benefit of using the Ext4 filesystem is its backward compatibility with the Ext3 and Ext2 systems. This improves performance and flexibility since some Ext4 features can also be implemented in Ext3 and Ext2 filesystems. In addition, the Ext3 and Ext2 filesystems can be mounted as Ext4.
  • Allocation improvements - Storage blocks are allocated more efficiently by the Ext4 file system before being written to the disk. This greatly enhances the read and write performance.
  • Journal Checksums - The Ext4 filesystem leverages the checksum option to minimize the risk of file corruption. The checksum option performs frequent checks to probe for errors in the block volume. By so doing, journaling time is reduced and performance reduced.
  • Faster filesystem checks - In addition to journal checksums, Ext4 yields faster filesystem checks, For example, the fsck command will run faster and give results in a shorter time compared to the earlier versions such as Ext3 and Ext2.
  • Improved timestamps - Ext4 implements timestamps measured in nanoseconds, an improvement from the granularity of second-based timestamps which is considered inadequate. In addition, another 408 years have been added to the timestamp to address the capped limit of the year 2038.
  • Unlimited number of sub-directories - The Ext4 filesystem does not put a limit on the number of subdirectories that can be created in a single directory, except the directory size itself. In Ext3, a directory can only have a maximum of 32,000 sub-directories. Ext4 introduced the HTreeindices feature to increase the entries that can be stored in a directory.
  • Transparent Encryption - Support for transparent encryption was implemented for the Ext4 filesystem in Linux kernel 4.1 back in June 2015.

The XFS filesystem

Originally Developed by Silicon Graphics in 1993, the XFS filesystem prides itself in being a stable and high-performance 64-bit journaling filesystem. The XFS filesystem was built to support large filesystems of up to 18 exabytes and extremely huge files. The filesystem is designed for systems with large disk arrays, large CPUs, and those that need to store large files.

XFS is popularly known for providing high scalability of I/O threads and for its great performance in handling big files.

The XFS filesystem is the default filesystem in RHEL, CentOS, and other RHEL-distros such as Oracle Linux, Rocky Linux, and AlmaLinux.

Main features include:

  • Support Larger filesystem - XfS support file system size upto 1PiB whereas Ext4 support up to 50TiB. The supported size of the filesystem may vary depend on Linux distribution versions.
  • Delayed allocation - Use lazy evaluation techniques for file allocation. block allocation occurs only when the data is finally flushed to disk and helps reduce fragmentation and increase performance.
  • Online defragmentation and file system growing
  • Sophisticated metadata read-ahead algorithms
  • Metadata journaling - Metadata journaling is a feature that guarantees filesystem consistency in the event of a sudden loss of power or a system crash.
  • Quota journaling - This takes away the need for lengthy quota consistency checks after a system crash.
  • Support for extended attributes - This enabled the system to associate several additional name/value pairs per file.
  • Online defragmentation and growth - You can defragment and enlarge the filesystem while mounted and active.
  • Storage Scalability - The XFS filesystem goes to impressive lengths to support large file systems, large directories, and a huge volume of files up to exabytes of capacity.
  • Efficient disk space management - XFS also provides scalability for efficient disk space management thanks to B-Tree indexing.

Conclusion

It's an important decision to choose the appropriate filesystem for your application. When making the decision needs to consider how much larger the server, I/O workload you expect, throughput and latency, size of the files, how much downtime the application can suffer, and more.

That was an overview of the XFS and Ext filesystems. We have outlined in depth the benefits that each file system offers. With this information in mind, you can make an informed decision on which filesystem to choose for your operating system.

Leave a Comment