ZFS vs EXT4 vs BTRFS: What is the best file system for NAS


You can also be interested in these:


When purchasing a NAS from a particular brand, it is important to consider which file system is best between ZFS vs EXT4 vs BTRFS. File servers are much more complex than they seem, as in addition to the device and its hardware, the file system is a crucial aspect that will largely determine the capacity, security, speed, and scope of work of the NAS or server.



It is essential to choose the most suitable file system for each situation, taking into account that the needs of a casual home user are different from those of a company or corporation. Each system has its advantages and disadvantages, but in general, EXT4 is probably the most well-known for being the typical Linux file system.

What is a NAS file system and what is it used for?

A file system is a structure designed to store, retrieve, and organize data in such a way that the operating system (OS) can work with them efficiently and orderly. If there were no file system, the data would be saved as binary strings without order or information about their size or location, which would make it difficult for the system to detect significant elements.

One of the main functions of the file system is to manage the available space on the hard drive, assigning the necessary space to store files and allowing access to those already saved. Considering that hardware-level information is composed of zeros and ones in sequences, without a system imposing order, it would be impossible to interpret which data is being read at any given time.

Each operating system uses its own file system, and the type of device used can also influence the available file systems. Some common examples include Windows NTFS volumes, exFAT used for flash drives, and FAT32 for older USBs. The file system also handles metadata associated with storage, access rules and privileges, encryption, and error recovery, a fundamental part for NAS, folders, and other aspects.

Each piece of data is stored in fixed-size blocks, which are assigned memory addresses so that they can be located. In mechanical hard drives, these blocks are called sectors, while memory cells are used in solid-state drives. File systems use a partition table to define the logical storage structure of the data, which allows them to handle different amounts of memory addresses according to their capacity. This is fundamental in determining the file system’s capacity.

ZFS vs EXT4 vs BTRFS file systems

File systems like ZFS, EXT4, and BTRFS may seem strange or unfamiliar, as they are used in servers, NAS, and in general, Linux-based operating systems. In contrast, NTFS is used in Windows, and HFS is used in Mac OS. Perhaps these file systems are more familiar, especially the typical FAT or its variants for external USB memories.

Next, we will examine the main features of each of these systems to determine which is best for specific applications.

EXT4

Let’s start with EXT4 (Fourth Extended Filesystem), which was introduced in 2006 as an update to EXT3 for Linux-based operating systems. This file system is defined as transactional (with journaling), a mechanism that keeps track of changes made to stored data that are still to be confirmed. This ensures the presence of the latest version of the file to prevent corruption in case of sudden failure.

Among the improvements in version 4, support for volumes of 1 EiB and files of 16 TiB is included, improvements in the Extents block scheme (set of contiguous physical blocks) that reduce fragmentation, resulting in faster reading and writing of data, with less hardware resource consumption.

EXT4 is forward and backward compatible, which means that EXT3 can be upgraded to the latest version while maintaining the old structure to be read and modified by EXT4. However, an EXT4 structure cannot be converted back to EXT3. The limit of subdirectory creation is doubled from 32,000 to 64,000, and 256-bit AES encryption is supported.

EXT4 incorporates a new space reservation feature for files that does not require padding with zeros, and tries to allocate contiguous blocks whenever possible, known as persistent allocation. Another related feature is Allocate-on-flush or delayed memory reservation, which reserves a block of memory just before the data is written to disk, optimizing resources and reducing fragmentation. EXT4 also features online defragmentation and a more efficient file system check, which skips unassigned blocks.

ZFS

ZFS (Zettabyte File System) is a file system developed by Sun Microsystems and released in 2005 for Solaris. This system is characterized by its large addressing capacity with a word width of 128 bits, which allows it to support volumes of 16 EiB and files of 16 EiB. ZFS also supports volume and storage space management and block-based control functions, which is very important.

In terms of security and data recovery, ZFS is considered the most advanced system for NAS. It uses the so-called Storage Pools, which are simple virtual storage spaces, an additional layer on top of traditional systems that use a separate volume manager. It also introduces the concept of vdevs or virtual devices for the allocation of each storage device, whether local or remote.

Storage Pools in ZFS can be simple (without redundancy, like a normal hard drive), mirror (in mirror, like a RAID 1), or RAID-Z (using parity in 3 or more vdevs, like a RAID 5). ZFS is compatible with mechanical hard drives and SSDs, for which the ZIL or ZFS Intent Log is defined. It is a cache implemented from the vdevs called an intent log, which reduces overhead in the data writing process in the system, which as we will see below, is quite unique.

Copy-on-Write (COW) is the block-level transactional model that ZFS uses for data writing, ensuring integrity. A 256-bit checksum is performed that is checked each time the block is read to ensure it has not been corrupted or deleted. In ZFS, data is never overwritten, but stored in a different block to avoid losing the original data in case of sudden failure. The copy-on-write system can generate high fragmentation in mechanical hard drives and SSDs, negatively affecting performance. That’s why the ZIL was created.

ZFS vs EXT4 vs BTRFS: What is the best file system for NAS

ZFS allows the creation of quotas and advanced management features such as permissions and even separate file systems for each user. The system uses variable block sizes of up to 128K, with the ability to distribute write load evenly across pools. In ZFS, data is not overwritten, so when a snapshot is taken, only new data is written, while old data that is common is preserved.

There are two types of file systems in this system:

  • Filesystem: This system allows you to create directories and store data by default, and can be configured as a mount point without an fstab file.
  • Zvol: This is a pseudo-block device used for swap files or virtual disks, such as machine virtualization. This dataset also supports snapshots, just like the Filesystem.

The file system evenly distributes write load among devices, and is capable of expanding the zpool when more devices are added to optimize the writing process through variable stripe sizes. Block-level data processing is excellent for data integrity, but requires significant hardware power for processing, including multi-core processors and at least 16 GB of DDR4 RAM.

BTRFS

BTRFS is the latest file system we present, and began development in 2007 by Oracle Corporation as a replacement for EXT4. BTRFS improves file addressing capacity to 16 EiB and volume sizes up to 16 EiB, just like ZFS. In fact, BTRFS is also a copy-on-write system to support fault tolerance and file recovery, and provides easy management. Additionally, BTRFS can be upgraded from EXT3.

When we talk about the BTRFS file system, we can say that its features are not very different from those of ZFS, such as its COW system, which allows the creation of writable snapshots and snapshots of snapshots. It also features block-level Mirroring and Stripping techniques, the ability to create subvolumes, and dynamic inode allocation, meaning the system does not set a maximum number of files.

As a suitable system for NAS, the BTRFS file system allows AES-NI encryption, support for various RAID structure algorithms, optimization for SSD storage, incremental backups, advanced compression function, and the ability to increase or decrease volume size online, which is related to the aforementioned inode allocation.

Performance and usage of ZFS vs EXT4 vs BTRFS

Now that we know the main characteristics of these three file systems, it’s important to discuss where and when it’s best to use them. In this regard, we can rely on a performance analysis conducted by the Phoronix website, which used an Intel Optane SSD in different RAID modes to compare file systems such as ZFS vs EXT4 vs BTRFS, among others, like XFS.

Overall, except for application launch time, benchmark results show that ZFS is the slowest file system in terms of read and write speed due to its COW operating type, while EXT4 is usually the fastest system.

For personal and SOHO use, EXT4 is the most commonly used file system in Linux systems. It is suitable for PC platforms and network servers, and is also the default system in NAS using the QTS operating system from QNAP.

EXT4 is a robust file system with a large addressing capacity for mounting RAID. If high file transfers are prioritized without the need for deduplication and COW, EXT4 offers better read and write performance.

ZFS for enterprise-level NAS, mainframes, and Oracle

ZFS is ideal for Enterprise-level NAS, mainframes, and Oracle due to its excellent security and fault recovery. While its affinity with Oracle products is evident as its creator, its capabilities exceed the needs of a small business and target larger operations.

In the NAS segment, QNAP supports the ZFS file system in its QuTS Hero system. With this system, all functions can be obtained for expensive and powerful equipment such as Intel Core or Ryzen CPUs and multi-level RAID-Z configurations. This is a way to bring the benefits of ZFS to locations other than rack servers and can be easily managed through a graphical environment.

BTRFS for enterprises

BTRFS is another file system related to Oracle products. It offers simpler management than ZFS, but does not sacrifice advanced elements such as COW or robustness against information loss. BTRFS could be used in situations similar to those of ZFS, but provides better performance in opening instances and data transfer on SSD units and All-Flash RAID systems.

Synology, a clear rival of QNAP in the enterprise NAS device market, regularly uses the BTRFS file system for its operating system. Although the user interface offers simpler management, it does not have as many functionalities as QuTS Hero with ZFS.

Conclusion on ZFS vs EXT4 vs BTRFS systems

In conclusion, it is important to highlight that the possibility of using different file systems will always be determined by the platform. Although we have not mentioned the XFS system in detail, it is another system that is also available for use.

In summary, Linux offers a wide variety of possibilities in terms of security and data management compared to Windows Server, making it a popular choice for NAS systems based on the Linux kernel.


More stories like this