When buying a NAS of a certain brand, we must ask ourselves the question of which file system is better ZFS vs EXT4 vs BTRFS? The world of file servers is more complex than it seems, since under the device itself and its hardware we have an aspect as important as the file system, and this will largely determine the capacity, security, speed, and working scope of the NAS or server.
A casual home user does not have the same needs as a company or even large corporations, therefore the most comfortable system to work with must be chosen at all times. Each one will have its advantages and disadvantages, of course, starting from here surely Ext4 will sound familiar to all of you because it is the typical Linux file system.
File system what is it and what is it for
A file system is a structure that is responsible for storing, retrieving, and organizing data so that the operating system (OS) can work with it in an orderly and efficient manner. If there were no such system, the data would be binary strings stored consecutively without order or information about their location and size, making it impossible for the system to detect “sense” items.
Its basic functions are to manage the space inside the hard drive, in order to allocate space to the files that are going to be recorded, and provide access to those already present. Let’s take into account that at the hardware level the information is zeros and ones arranged in chains, without a system that imposes order it would be impossible to interpret what data is being read at any given time.
Each operating system will have its own file system to work with, and depending on the type of device, different systems can be applied as needed. We will all have seen the NFTS volumes of Windows, exFAT of flash drives, or even FAT32 of older USBs at some point. The file system is also in charge of everything related to the metadata associated with storage, access rules, and privileges, encryption, or error recovery, this part is very important for NAS, folders, etc.
Each data is stored in blocks of the same size, as in mechanical hard drives called sectors, and in SSD memory cells, which will be assigned to memory addresses in order to locate them. The file systems have the so-called partition table that defines the logical structure where the information is stored, and which, depending on the word width that it can handle, will be able to work with a greater or lesser number of memory addresses. This will be critical in determining the capacity of the file system.
ZFS vs EXT4 vs BTRFS File Systems
Perhaps these types of file systems are strange or unknown to you, but normal, since they are used in the environment of servers, NAS, and Linux systems in general. In Windows NTFS is used, while in Mac OS it is HFS, perhaps these will sound familiar to you, especially the typical FAT or its variants for external USB memories.
Let’s see the main characteristics of each of these systems to know which one is better for certain applications.
We started with Ext4 (fourth extended filesystem), the file system that was announced in 2006 as an upgrade to ext3 for Linux-based operating systems. The system is defined as transactional (with journaling), a mechanism that tracks changes that occur in the stored data, and that are yet to be confirmed. In this way, the presence of the latest version of the file is ensured so that, in the event of a sudden failure, there is less probability of corruption.
Among the improvements in version 4 we have support for 1 EiB volumes and 16 TiB files, improvements in the Extents block scheme (set of contiguous physical blocks) that reduce fragmentation, and therefore, speed improvements in reading and writing consuming less hardware resources.
Ext4 is a backward and forwards compatible system, so Ext3 can be upgraded to the latest version keeping the old structure to be read and modified by Ext4. However, an Ext4 structure cannot be converted to Ext3. The subdirectory creation limit is doubled from 32,000 to 64,000, supporting AES-256-bit encryption.
Ext4 adds a function to allocate space to files without padding them with zeros, and contiguous blocks will be reserved as far as possible, this is called persistent allocation. Allocate-on-flush or delayed memory allocation is another related function that allocates a block of memory just before data is written to disk, optimizing resources and reducing fragmentation. It features online defragmentation and more efficient file system checking by skipping unallocated blocks.
ZFS (Zettabyte File System) is a file system that was developed by Sun Microsystems and released in 2005 for Solaris. This stands out for its great addressing capacity with its 128-bit word width to support 16 EiB volumes and 16 EiB file sizes. It supports volume and storage space management and block-based control functions, this is very important.
We can consider it the most advanced system for NAS in terms of security and recovery against data loss. It uses so-called Storage Pools, which are simple virtual storage spaces, an additional layer compared to traditional systems that use the volume manager separately. The concept of vdevs or virtual devices is introduced for the allocation of each storage device, whether local or remote.
Storage Pools can be simple (no redundancy like a normal hard drive), mirror (mirrored like RAID 1), or RAID-Z (using parity on 3 or more vdevs like RAID 5). ZFS supports both mechanical hard drives and SSDs, for which the ZIL or ZFS Intent Log is defined. It is a cache implemented from the vdevs called intent record (or intentions), to reduce the overhead in the process of writing data to the system, which as we will see now is quite peculiar.
Copy-on-Write (COW) is the block-level transactional model that ZFS uses to write data while ensuring integrity. It consists of performing a 256-bit checksum that will be checked each time the block is read to ensure that it has not been corrupted or deleted. Data is never overwritten in ZFS, but the new data is stored in a separate block, so as not to lose the original data in the event of a sudden failure. The copy-on-w systemrite can generate high fragmentation on both HDD and SSD, negatively affecting performance, which is precisely why the ZIL is created.
ZFS allows you to create reserved quotas or advanced management elements like permissions and even separate file systems for each user. Blocks of variable size up to 128K are used, with the capacity to distribute the write load equally in the pools. This system does not overwrite data, so when we take a snapshot, only the new data is written, keeping the old ones that are common.
There are two types of file systems:
- Filesystem: the system that by default allows creating directories and storing data, being able to configure it as a mount point without the need for a fstab file.
- Zvol: is a pseudo-block device that is used for swap files or for virtual disks, for example, machine virtualization. This dataset also supports snapshots just like Filesystem.
The system distributes the writing load equally among the devices, being able to expand the zpools in case of adding more devices. In this way, it is intended to optimize the writing process by means of bands of variable size. Block-level data processing is great for data integrity, but a problem for system resources, since it requires a lot of hardware power for your processor, we are talking about multi-core processors and 16 GB of RAM DDR4 minimum.
Finally, we have the Btrfs (B-tree File System) system that began to be developed in 2007 by Oracle Corporation as a substitute for Ext4, improving the addressing capacity of files up to 16 EiB and volume sizes up to 16 EiB, just like ZFS. In fact, it is also a copy-on-write system to support fault tolerance and file recovery, providing easy administration, as well as being able to update Btrfs from Ext3.
The features that are detailed about this file system will be not very different from ZFS because of its COW system, for example, the creation of writable snapshots and snapshots of snapshots. It has Block-level Mirroring and Stripping techniques, the ability to create sub-volumes or dynamic inode allocation, that is, the system does not establish a maximum number of files.
As a good system for NAS, it supports AES-NI encryption, support of different RAID structure algorithms, optimization function for SSD storage, incremental backups, advanced compression function as well as the possibility of increasing or reducing volume size online, related to the above mentioned about inodes.
Before finishing, we are going to compile in a table the main characteristics of the three file systems studied.
|maximum volume size||16 EiB||16 EiB||1 EiB (4K blocks)|
|maximum size of a file||16 EiB||16 EiB||16 TiB (4K blocks)|
|Maximum number of files||2 48||2 64||2 32|
|Maximum file name size||255 bytes||255 byte||255 byte|
|Maximum number of snapshots||2 48||2 64||2 32|
|encryption||yes, transparent||Yeah||yes, transparent|
|Compression||yes, transparent||yes, transparent||Yeah|
ZFS vs EXT4 vs BTRFS Performance and Usage
We know the main characteristics of these three file systems, so it’s time to talk about where and when it is best to use them. We can rely on a performance analysis carried out by the Phoronix website with Intel Optane SSD in different RAID modalities for ZFS vs EXT4 vs BTRFS file systems among others such as XFS.
Images obtained from www.phoronix.com
Except for the application launch time, the rest of the benchmarks show that in reading and writing ZFS is the slowest file system due to its COW type of operation, while Ext4 will normally be the fastest
Images obtained from www.phoronix.com
In a previous performance test for the two platforms on Linux with HDDs and SSDs, the results indicated this same effect, with ZFS being the slowest system on both types of storage.
Ext4 for personal and SOHO use
Being the most generic file system, Ext4 is the most used in Linux systems for generic use, that is, PC platforms and even network servers. On NAS it is also the default system used by QNAP in its QTS operating system.
It is a robust system with great addressing capacity to mount RAID, offering greater reading and writing performance if what we prioritize is precisely high file transfers without the need for deduplication and COW.
ZFS for Enterprise-level NAS, Mainframes, and Oracle
ZFS’s affinity with Oracle (formerly Sun) products is evident from its creator, but its status as the best system in terms of security and failover makes it perfect for server mainframes, supercomputers, and databases. Its capabilities typically exceed the needs of a small business, so it targets larger operations.
In the NAS segment, QNAP and its QuTS Hero system supports the ZFS file system, getting all its features for very expensive and powerful equipment like Intel Core or Ryzen CPUs and multi-level RAID-Z configurations. It is a way of bringing the benefits of this system closer to locations that are not rack servers, and can be easily managed using a graphical environment.
btrfs for companies
Also similar to Oracle products, it offers easier management than ZFS without giving up advanced elements such as COW or high robustness against information loss. Your application could be similar to ZFS, although it will give extra performance when opening instances and transferring with SSD drives and All-Flash RAID systems.
Synology regularly uses this file system for its NAS operating system, a clear rival to QNAP in this section with its devices designed for the business environment. At the interface level it offers easier administration, but it does not have as many features as QuTS Hero with ZFS.
Gathering features – conclusions about ZFS vs EXT4 vs BTRFS
Let’s look at a summary of advantages and disadvantages for each file system.
EXT4 advantages and disadvantages
- Low consumption of hardware resources
- Extended SSD lifespan
- Reduce fragmentation
- Persistent Assignment and Checksum
- easy administration
- Best option for personal use and basic hardware
- Does not have disk and volume management
- Invisible RAID degradation
- It does not have a Copy-on-Write function or deduplication
- Has no transparent compression
ZFS advantages and disadvantages
- Copy-on-Write and ZIL
- Virtual Storage Spaces and RAID-Z
- Protection against data corruption
- Efficient compression system in snapshots, and files
- Integrity check and self-repair
- Compression and transparent deduplication
- AES-NI encryption
- Extended SSD lifespan
- Best Choice for Mainframe and Enterprise
- High consumption of hardware resources
- Read and write slower than others
- COW increases fragmentation
briefs advantages and disadvantages
- Copy-on-Write and deduplication
- transparent compression
- AES-NI encryption
- Self-healing fault tolerance
- easy to manage
- Supports larger number of files
- Mirroring and Stripping at the block level
- Good balance between R/W speed and resource consumption
- Best option for companies
- COW increases fragmentation
- Under continuous development, susceptible to RAID implementation issues
- Less redundancy than ZFS
With this summary we finish the article, but not before commenting that the possibility of using the different file systems at the user level will always be predetermined by the platform. Perhaps the XFS system has been left out, but it is a system with which we are not familiar.
It is clear that in terms of security and data management, Linux offers a wide range of possibilities compared to Windows Server, for example, which is why all NAS systems are based on the Linux kernel.