Btrfs Vs. Ext4: Essentials, Benefits, And Disadvantages

File systems control where and how your data is stored and retrieved from a storage device. Windows and macOS users have little reason to worry about file systems since NTFS and HFS+ are the only choice of filesystems they have, respectively. 

Linux users have the flexibility to choose the file system their machine uses since the kernel supports a variety of these. Ext4 is the default option for Linux users. Still, there is another file system called Btrfs you could consider using. 

With a part of the Linux community pushing for the adoption of Btrfs as the default file system, it’s essential to understand the functionalities, advantages, and disadvantages of both.

We will walk you through all you need to know in this post.

What is the Ext4 Filesystem?

The first version of the Extended filesystem (Ext4) came out in October 2008 and improved upon its predecessor, Ext3. Many Linux distros began using Ext4 as the default filesystem after it launched. 

Ext4 is a journaled filesystem, which simply means that it “journals” the location of the files on the disk and keeps track of the changes on the disk.

Interestingly, the first version of the Ext4 filesystem, the Extended filesystem (“Ext”), came out in 1992 for the Minix OS. It was later developed for Linux.

What is the Btrfs Filesystem?

Unlike the Ext4 filesystem, the B-Tree filesystem is a copy-on-write filesystem. This means that when a file is duplicated on Btrfs, it does not create another copy of the file. Instead, the file is shared between the original and the phantom “copy” file. 

On the other hand, if a user wants to modify a data extent (contiguous storage area), the extent is copied to a different location and then modified. In this way, Btrfs can prevent data loss in the event of a power loss.

However, the filesystem also tends to fragment big files, which means you will need to defragment the disk periodically.

Its name comes from B-trees, which the filesystem uses to store internal file structures. Oracle first developed Btrfs in 2007, but companies such as Facebook and Redhat have since contributed to its development.

Developers built Btrfs so they could have a filesystem that has desirable features such as snapshots and checksums in it. 

Features of the Btrfs Filesystem

Some of the Btrfs’ best-celebrated features include:

#1 Support for Storing Massive Files

Btrfs can store files up to 2^64 bytes in size, which is equal to 16 exbibytes. To help understand how big that is, you can think of it this way: 

A petabyte is equal to a thousand terabytes, and an exbibyte is equal to 1153 petabytes. So, theoretically, a Btrfs filesystem can manage 18446.7 petabytes of data.

#2 Efficient Storage

Since Btrfs provides extent-based storage, the overhead in every file’s metadata is reduced significantly. This allows Btrfs to manage the disk’s storage and performance more effectively.

The filesystem also provides efficient storage for smaller files by packaging the small files as metadata itself.

#3 RAID Support

Btrfs comes with support for RAID 0, 1, and 10, enabling data stripping and mirroring.

#4 Easy Defragmentation and Resizing

Users can perform defragmentation and partition resizing when the Btrfs filesystem is online.

#5 Dynamic Inode Allocation

By allocating inodes to files on an as-needed basis, Btrfs prevents the depletion of inodes and saves them in case the user has a large number of small files on the disk.

#6 Snapshot Support

One of the best things about Btrfs is its snapshot support. Creating a snapshot of your filesystem is easy, and you can restore the data on the disk elsewhere in the event of data corruption without much hassle.

#7 Checksum Support

Unlike many other filesystems, Btrfs supports checksums, which are small data blocks that reduce the chances of data corruption. These data blocks are stored in the filesystem and continually checked for errors and data corruption.

#8 Optimized SSD Support

SSDs have become the go-to storage option for computer users in the last decade. These drives offer speed and stability and are surprisingly reliable. Btrfs improves the performance of SSDs by optimizing the read and write performance. It also enhances the life of an SSD.

Comparing Ext4 and Btrfs Filesystems

Contrasting the key features of the two file systems is the right way to understand which one is objectively better:

#1 File System Type

While Ext4 is a journaling filesystem, Btrfs is a CoW filesystem.

#2 Number of Devices Supported

Using a single filesystem across multiple devices makes the drives more reliable and can also offer more capacity. Btrfs comes with RAID support, allowing you to directly manage several devices on a filesystem level.

On the other hand, Ext4 does not support multiple devices. However, you can use third-party volume managers to spread the filesystem across multiple disks and devices.

#3 Deduplication

Deduplication is a filesystem feature that automatically removes duplicates of data from a disk. Btrfs implements this feature by replacing identical data blocks with logical links to the same copy of the data block. In this way, the filesystem stores the user a lot of space.

In contrast, Ext4 does not come with the deduplication feature.

#4 Compression

Btrfs comes with compression algorithms baked into the filesystem, allowing data to be compressed at filesystem-level right when written to the system. Ext4 does not come with compression support built-in.

#5 Maximum File and Partition Size

Ext4 can handle one exbibyte of data, which is equal to over a million terabytes of data. The filesystem can handle a maximum file size of 16TiB. Hard drives of this size are available, but they are expensive and difficult for users to get their hands on. 

On Ext4, you can create a maximum of 2^232 files. In contrast, on Btrfs, you can create a maximum of 2^264 files. Furthermore, Btrfs can support a partition that is 16 EiB large. 

#6 Checksum Support

Ext4 does not guarantee the integrity of data in any way. On the other hand, Btrfs uses a checksum to ensure that the data doesn’t corrupt.

#7 Snapshot Support

Since Btrfs support CoW, users can create writable, read-only snapshots of files with ease. Ext4 lacks this feature and does not allow you to create snapshots.

#8 Block Sub-Allocation 

It is a feature where big files are stored in blocks in a way that the tail space at the end of the block is used as much as possible. It involves storing parts of another file block into the tail block of a file block to save space.

By using block sub-allocation, the filesystem packs the tails of blocks with inside other blocks, increasing performance and efficiency.

Ext4 does not have block sub-allocation and tail packing features.

Conclusion 

The Ext4 filesystem has been adopted as the default filesystem for over a decade and has proven to be a reliable and stable filesystem. In addition to being suitable for daily use, it is efficient enough to keep your data safe in most events of power loss.

The years of testing and bug fixes make it a rock-solid option that is hard not to recommend. However, it does not support modern features such as compression and deduplication.

On the other hand, Btrfs can handle up to sixteen times the data that Ext4 can. While this doesn’t do much for the average Joe, it can be helpful to enterprise entities. Features such as CoW, checksums, and snapshots make it seem like a worthy upgrade at first glance.

However, Btrfs is not stable. Many Btrfs users complain that the partition gets corrupt after a period – sometimes two months, other times two years – which inherently makes ext4 more reliable than Btrfs.

Furthermore, Ext4 can transfer files faster than Btrfs, making it more useful to the average user.

If you’re picking between the two, you should go for ext4 until they fix the corruption issues it has.