Btrfs vs Ext4 – Functionalities, Strengths, and Weaknesses

Written by: Linuxopsys   |   Last updated: June 23, 2022

A file system controls where, how,  and when data is stored and retrieved from a storage device. An efficient file system is necessary for everyday system processes. The Linux kernel supports a variety of file systems. The most commonly used are Ext4, Btrfs, XFS, and ZFS which is the most recent file system released back in 2018. Each of these file systems has its own way of organizing data, merits, and demerits.

In this tutorial, we will check Btrfs against Ext4 filesystem, and seek to understand their functionalities, strengths, and weaknesses.

Ext4 Filesystem

Ext4 is the default filesystem for many Linux distributions.  It was released in October 2008 with Linux kernel 2.6.28. Ext4 is the fourth version of the  Extended filesystem and a successor to Ext3. 

Ext4 is a robust file system that has been in use for a long time now. It is a journaled file system, which means that it keeps a "journal" of where files are located on the disk and keeps track of any other changes to the disk.

Btrfs Filesystem

Btrfs or the B-Tree file system is a newer, modern, open-source filesystem. It's a copy-on-write (CoW) filesystem tailored for Linux systems and Its name is derived from the use of B-trees to store internal file structures. In the CoW filesystem setup, when data is modified, the filesystem copies modifies, and writes the data back to an available location on the filesystem.

Since data is copied and modified to a different location on the filesystem, this eliminates the risk of data corruption in the event of a power outage, just to give an example. It's important to point out that during modification, the original data is preserved and remains unchanged.

The greatest drawback with the Btrfs filesystem is the tendency of big files to becomes easily fragmented, and therefore, periodic defragmentation is required.

Development of the Btrfs began back in 2007 at Oracle, but other major companies including SUSE, Facebook, Redhat are contributing to its development. Btrfs exists because developers wanted to expand the functionality of a file system to include features such as snapshots, checksum, and so on.

BTRFS features

Some of the interesting features offered by btrfs include:

1) Support for huge files

The Btrfs filesystem can support up to 264  bytes, which is the equivalent of 16EiB or exbibytes! Now that's a massive storage size!

2) Efficient file storage

Btrfs provides extent-based file storage. This is described as a contiguous area reserved for file storage. The overhead in file metadata is greatly reduced, and small metadata directly contributes to greater storage efficiency and performance.

Still of efficient file storage, Btrfs provides efficient storage for smaller files by packaging them as metadata.

3) Built-in RAD support

The Btrfs filesystem includes support for RAID 0 ( data stripping ) , 1 (Data mirroring) and RAID 10 ( data stripping & mirroring )

4) Online defragmentation and resizing

With Btrfs, it's possible to perform defragmentation and resizing even when the file system is online.

5) Dynamic inode allocation

Btrfs provides dynamic allocation of inodes. It allocates inodes to files as and when required and this helps to prevent the depletion of inodes in the event you have very many small files ont eh filesystem.

6) Writeable and read-only snapshots

Another wonderful feature that Btrfs provides is support for snapshots. You can readily create a snapshot of your filesystem and leverage it to restore data elsewhere in the event of accidental deletion or corruption of data.

7) Support for checksums

Another important feature is support for checksums. Checksums are small blocks of data that avert the chance of silent file or data corruption, something which other filesystems do not provide. Checksums are stored in the filesystems and continuously keep and eye on signs of filesystem errors and corruption of data.

8) Optimized support for SSD drives

SSD (Solid State Drives) drives sure do provide a decent degree of speed, reliance, and stability in a PC. The Btrfs filesystem further enhances their performance by optimizing their read and write performance and thus improving the life of the SSD.

Comparison between Ext4 and Btrfs Filesystems

Let us know draw a comparison between the two filesystems on various key features.

1. Journal and Copy-on-Write Support

This is the first major difference that comes out between the two filesystems. The Ext4 filesystem is a journaling filesystem while Btrfs is a  Copy-on-Write (CoW) filesystem.

2. Multiple Devices Support

Spreading a single file system across multiple devices offers certain advantages such as increased capacity and greater reliability. Btrfs has built-in RAID support that makes it easy to manage multiple devices at the filesystem level.

Ext4 filesystem does not have built-in support  for multiple devices. You will have to use 3rd-party logical volume managers like LVM 2 to span your file system over multiple devices and disks.

3. Filesystem-level Deduplication: 

Deduplication is a feature that automatically removes duplicate copies of data from a filesystem to save on disk space. Btrfs filesystem supports deduplication by replacing identical blocks in the file system with logical links to a single copy of the block. This feature saves a huge amount of disk space.

Ext4 filesystem does not support deduplication.

4. Filesystem-level Compression

The Btrfs uses compression algorithms to support filesystem-level data compression. This means that  data will be compressed automatically as it is written to the file system.

The Ext4 filesystem does not have built-in compression support.

5. Maximum Partition and File Size 

The largest partition you are allowed to make with ext4 is 1 exbibyte---the equivalent to around 1,152,921.5 terabytes. The maximum file size is 16 TiB, which is much bigger than any hard drive a regular consumer can currently buy.

Btrfs supports a maximum partition and file size of up to 16Eib. 

Ext4 allows you to create a maximum of  232 (= 4,294,967,296 ~= 4 billion) files. Btrfs allows you to create a maximum of 264 (= 18,446,744,073,709,551,616 ~= 18 quintillion) files.

6. Checksum/ECC Support

The Btrfs filesystem uses CRC32C checksum to ensure data integrity and avoid data corruption. The Ext4 filesystem does not guarantee the integrity of your data.

7. Snapshot support

The Btrfs filesystem supports read-only and writable snapshots of the file. A snapshot is a subvolume that shares its data and metadata with another subvolume, using COW capabilities.

The Ext4 filesystem does not support creating snapshots of the filesystem.

8. Block sub-allocation and Tail packing

Block sub-allocation is a feature where large files are stored in blocks while making efficient use of tail space at the end of the last block. Block sub-allocation is a method to store parts of another file block to the tail block and save disk space.

Btrfs has been designed to take advantage of this available space and can pack the tails of several blocks in with other files.  This improves file system performance and increases storage efficiency.

Ext4 does not support tail packing.

Conclusion

Ext4 filesystem is the latest release of the extended file system. Ext4 has been around for long and it has proven to be reliable and stable. It is recommended for everyday use. In case the power goes out, odds are ext4 will have kept your saved data safe.

Ext4 focuses on high-performance and scalability. It is a rock-solid option since it has been around for long, bringing with it all the years of system testing and bug fixes. Regardless of all its features, it doesn’t support data deduplication, compression, or encryption.

Btrfs on the other hand is a modern filesystem that can handle up to sixteen times the data of Ext4. This improvement is specifically important as Linux is now used within enterprise entities. Btrfs has many good features mentioned above such as Copy-on-Write, snapshots, checksums, and duplication. Btrfs is growing at a fast rate, but it is still not considered stable.

Until now, the ext4 seems to be a much better choice on the desktop system since it is the default file system, and it is faster than the btrfs when transferring files. The btrfs filesystem is worth looking into, but to completely replace the ext4 on desktop Linux might be several years later. 

SHARE

Comments

Please add comments below to provide the author your ideas, appreciation and feedback.

2 Comments

2 thoughts on “Btrfs vs Ext4 – Functionalities, Strengths, and Weaknesses”

  1. NTFS is also journaling, but with inbuilt compressions, and other creators not available in Ext 4.

    BTRFS is still unstable, despite the sponsorship of some Linux brand-name. Grub Customizer of improving, but still had difficulty with BTRFS partitions. Currently, Ext 4 is faster than BTRFS on desktop operating systems.

    The overall comparison for users seems to be that BTRFS might only be used for risk-taking adventurers.

    Reply

Leave a Comment