Is Btrfs a good file system?

Btrfs (B-tree file system, also pronounced as “Butter F S”, “Better FS”, “B-tree FS”, or “BtrFS”) is a modern copy-on-write (CoW) filesystem for Linux aimed at implementing advanced features while also focusing on fault tolerance, repair, and easy administration. It has been under development since 2007 by multiple contributors and is now merged into the Linux kernel.

According to ITSFOSS, Btrfs is designed to address the lack of pooling, snapshots, checksums, and integral multi-device spanning in Linux file systems ext3 and ext4. It brings modern features like snapshots, checksums, compression, and configurable partitions.

History of Btrfs

Btrfs was founded by Chris Mason in 2007 while working at Oracle. He created it to address the lack of advanced features in existing Linux filesystems like ext3 and ext4. Mason wanted to build a modern filesystem for Linux with advanced capabilities like snapshotting, copy-on-write, deduplication, compression, and online defragmentation.

According to LWN, the development of Btrfs was also motivated by frustrations with ext3 and the slow pace of ext4 development within the Linux community. Mason aimed to leapfrog ext4 by designing a next-generation filesystem with an emphasis on fault tolerance, repair tools, and efficient incremental backup capability.

The first version of Btrfs was released in 2007, and it quickly gained attention as a promising Linux filesystem of the future, though it was still marked experimental. After Oracle acquired Sun Microsystems in 2010, Mason and other key developers left Oracle to form the Btrfs startup company Fusion-io. Development continued in the Linux community, with major features added over time.

Features of Btrfs

Btrfs has several key features that set it apart from other filesystems like ext4:

Copy on Write

Btrfs uses a copy on write (COW) technique to implement snapshots and ensure data integrity. Instead of overwriting existing data blocks when they are modified, Btrfs allocates a new block and points to the new copy (Wikipedia). This allows previous versions of files and snapshots to be retained.

Snapshots

Btrfs supports lightweight filesystem snapshots, allowing the state of a filesystem at a given point in time to be saved. Snapshots use copy on write so that the snapshot retains the original state while the live filesystem can continue changing. Snapshots provide an easy way to rollback changes or recover deleted files (BTRFS).

RAID

Btrfs supports RAID 0, RAID 1, and RAID 10 configurations. Data and metadata can be striped or mirrored across multiple devices to provide redundancy and/or improved performance. Btrfs allows for combining drives of different sizes and adding/removing drives from a RAID array online (Btrfs features).

Compression

To save space, Btrfs allows compressing both data and metadata inline. Different compression algorithms like Zlib, LZO, and ZSTD are supported. Compression levels can be configured per file/folder. Inline compression provides transparent space savings without affecting performance (Wikipedia).

Advantages of Btrfs

Btrfs offers several key advantages over traditional filesystems like ext4:

Snapshots for backup/rollback – Btrfs allows you to create lightweight copy-on-write snapshots of the filesystem easily. These snapshots can be used to roll back changes or for backup purposes.

Efficient storage – Btrfs is designed for efficient storage utilization through features like thin provisioning, copy-on-write, deduplication, and compression. This allows you to store more data efficiently.

Flexible filesystem structure – Unlike traditional filesystems, Btrfs allows great flexibility in how you structure the filesystem, with features like subvolumes and snapshots.

Disadvantages of Btrfs

Despite the many advantages Btrfs offers, it is still not yet without its downsides. Some of the key disadvantages and concerns surrounding Btrfs include:

Immaturity – Btrfs is still considered an experimental file system in Linux. It was introduced in 2007, so it has not been battle-tested to the same degree as more mature options like EXT4. Being newer, it may have more bugs and stability issues.

Complexity – Btrfs is a very complex file system with many features. This complexity can make it harder to troubleshoot issues. Its RAID implementation also leads to a more involved setup process.

Performance concerns – In certain workloads, especially with many small files, Btrfs can suffer performance issues compared to EXT4. Benchmarks have shown slower speeds in some cases (Source: https://www.reddit.com/r/DataHoarder/comments/47abm6/btrfs_disadvantages/).

Performance Benchmarks

Btrfs performance has been thoroughly tested using industry standard benchmarks like Sysbench and iozone. According to benchmarks by Phoronix in 2010, Btrfs performed comparably to ext4 in sequential io, while lagging behind in random read/write performance [1]. However, Btrfs read performance was significantly faster than XFS in some tests. Over the years, continued improvements to the Btrfs codebase have helped increase performance.

More recent benchmarks in 2015 by Phoronix showed Btrfs on par with ext4 for SSD workloads, but still behind for hard drive performance [2]. Btrfs particularly excels at SSD caching and optimizing SSD storage. Comparisons to ZFS show the two file systems neck-and-neck in many benchmarks.

While historically Btrfs trailed behind ext4 in some performance metrics, modern benchmarks demonstrate excellent I/O throughput and steadily improving performance as the codebase matures.

## Adoption Rates

Btrfs adoption in the Linux ecosystem has been mixed. Several Linux distributions like openSUSE and Oracle Linux have made Btrfs the default file system. However, other major distros like Ubuntu, Debian, Fedora, and RHEL have not adopted it as the default yet.

openSUSE has included Btrfs support since version 11.2 and made it the default file system in 2013 with openSUSE 13.2 [1]. The developers cited features like copy-on-write, checksums, and snapshots as reasons for choosing Btrfs. Oracle Linux has supported Btrfs since version 6.5 in 2014 and made it the default for installations in 2015 with Oracle Linux 7 [2].

On the enterprise side, adoption has been more cautious. Red Hat Enterprise Linux included experimental Btrfs support up until RHEL 8 but decided to remove it completely citing stability concerns [3]. Ubuntu currently allows Btrfs as an option but recommends Ext4 for most uses. The need for long term stability in enterprise environments means file system changes happen slowly.

Real World Usage

Btrfs has seen adoption from some major companies and organizations despite its reputation as an unfinished filesystem. Facebook, for example, has used Btrfs in production since at least 2014 according to public presentations. They utilize features like writable snapshots and lightweight cloning to quickly roll out updates across thousands of servers. Facebook engineers have contributed many stability fixes and performance improvements to the Btrfs codebase as a result of their production use.

The Wikimedia Foundation, which runs Wikipedia, switched to Btrfs for its backend storage servers in 2012. Wikimedia cites improved performance, easier administration, and robust checksums as reasons for adopting Btrfs. According to diff.blog, Wikimedia operates over 300 PB of Btrfs storage as of 2022.

SUSE Linux has included Btrfs support and used it as the default filesystem since 2011. As a major Linux distro, SUSE’s faith in Btrfs lends credibility despite ongoing criticisms. SUSE appreciates built-in features like snapshots, checksums, compression, and thin provisioning that reduce storage costs for enterprise customers. Long-term production use by SUSE helps mature the filesystem.

The Future of Btrfs

There is some uncertainty surrounding the future development and adoption of Btrfs. While it was originally created by Oracle, some view Oracle’s contributions to the filesystem’s development as having slowed down in recent years[1]. Red Hat, another major backer of Btrfs, has also shifted focus to support the Stratis filesystem instead[2].

Some argue this means Btrfs is struggling to gain traction and its long-term viability is questionable[1][2]. Facebook is one of the major tech companies using Btrfs in production, but most enterprise distributions like RHEL are looking at other options like Stratis and ZFS[3]. The filesystem faces stiff competition and an unclear path forward.

Still, the Btrfs community continues developing new features and improvements. Some believe it still has a chance to succeed, but likely needs broader engagement from Linux vendors to demonstrate its feasibility as a default filesystem[3]. At the moment Btrfs seems to occupy a niche role, with uncertainty persisting around mainstream adoption.

[1] https://www.reddit.com/r/linux/comments/dobifs/sooo_is_the_future_of_btrfs_in_question_with/
[2] https://news.ycombinator.com/item?id=15177949

[3] https://www.quora.com/Is-BTRFS-a-Linux-file-system-doomed

Conclusion

In summary, Btrfs has some notable advantages over traditional file systems like ext4, including built-in RAID support, faster file system checks, copy-on-write snapshots, compression, and transparent checksums. However, it also has some disadvantages like lower performance in certain scenarios and lack of stability in older kernels.

Overall, Btrfs is a modern file system that introduces many useful features not found in ext4 and other legacy file systems. For users who need built-in RAID, snapshots, or compression, Btrfs can be an excellent choice. However, due to its complexity it still requires some caution, especially when stability and performance are critical. For most general use cases, ext4 remains a tried and true option.

In the future, as Btrfs matures and becomes the default on more distributions, it will likely eclipse ext4 as the top Linux file system. But for now, use caution and carefully evaluate if Btrfs is right for your needs.