Btrfs may be a “better” file system next to everything except ZFS, but what Btr actually stands for is not “better”, or “butter”, but B-Tree, a data construct employed in the design. Now that we’ve straightened that out, what is btrfs and how does it work?
What is Btrfs?
Btrfs is a next generation file system that’s been developed by a number of companies including Facebook, Fujitsu, SUSE, and Oracle. Fusion-IO, Intel, the Linux Foundation, Red Hat, and STRATO AG have also contributed. The feature most touted is the same copy-on-write technology used by ZFS to ensure data integrity.
Copy on write doesn’t mean you write the data then copy it, it means that new data is written to empty areas before old data is erased. Only upon the verified success of the new write is the old data rendered eligible for the scrap heap. This mitigates bit rot due to power failures, or anything else that might interrupt the write process.
Copy on write also allows you to safeguard data by taking a “snapshot” of a volume, i.e., mark all existing data blocks as non-erasable. Subsequently, they may be marked as non-active, but not actually erased and reused until any “snapshot” they’re included in is deleted.
While Btrfs may not have all of ZFS’s features, it has the majority of them, including storage pools, the aforementioned snapshots, sub-volumes (data sets in ZFS), RAID 5, RAID 6, mirroring, compression, extensive error-checking, and de-duplication, though the latter is currently done after the fact so as not to impact performance where ZFS compares before writing then throws away matching data. Inline de-duping is on the road map however.
Btrfs is a 64-bit operating system, compared to ZFS’s 128 bits. Even if it can’t handle the zetabytes that ZFS can, the 16 EiB (exbibytes) that Btrfs accommodates (8 EiB under Linux) is plenty for all but the most data-heavy applications. Certainly a Linux desktop or server.
Note: An Exbibyte (EiB) is a multiple of 1024, where Exabyte is a multiple of 1000.
The Btrfs wiki is a good place for more detailed info and to track currently implemented features.
The Upside
These are a few of many benefits of btrfs:
- Copy on write insures data integrity
- Handles up to 16 exbibytes of data (1 million tebibytes)
- Supports pools and multiple mount points (virtual volumes)
- Multiple compression and encryption options
The Downside
And here are a few downsides to btrfs:
- Some features are still being implemented
- Slightly slower than Ext4
- Not yet as feature rich as the more mature OpenZFS, which is also available for Linux
When to use Btrfs
For end users, there’s little reason to switch to Btrfs, as Ext4 is a fine file system with large capacity (1 EiB) and very good performance. However, there’s no reason not to switch either, as you don’t lose a whole lot in the way of speed, and you gain some peace of mind if your data is super sensitive.
For NAS, or servers, or larger volumes it’s a no-brainer. And no doubt Linux users will eventually be using it, as Ext4 is likely the last iteration of that venerable file system.
This article was amended on 6/19/2020 by the author to correct the discussion of file capacity.