There are many compelling reasons to use a modern Copy-on-Write, CoW for short, filesystem. These include low-cost snapshots and incremental backups. If that’s not compelling, the two most popular open source CoW filesystems, OpenZFS and Btrfs, offer many more features. Compression, redundancy, deduplication, native encryption, online defragmentation, and data integrity checking on every read are just a few.

CoW

Making a case for CoW is easy, but why make the change? Two key features made this change an inevitable one for me: bit rot protection and the ability to perform low-cost, incremental backups.

I’ve been struck by bit rot on a couple of occasions leaving me with corrupted music files. Unfortunately at the time, all my previous backups held only the corrupted files so the data was lost. While this wasn’t tragic by any means, it still bothered me. How would I know if a stray bit of radiation fried any of my other files? Would I notice in time to recover them? What are the odds of discovering my tax documents are corrupt during an audit by the IRS?

CoW solves this problem in two ways. It will detect such corruption at the time of reading the file or during a scrub, where all data and metadata is verified against the stored checksums. In my circumstance, the issue would have been caught much sooner giving me the opportunity to restore the file from a recent backup.

To the other point, CoW provides a robust backup solution through snapshots and incremental sends and receives. Taking a snapshot of an entire CoW system is practically no cost.[1] While snapshots shouldn’t be confused with backups, they provide the foundation for incremental sends and receives. This allows sending only the changes since the last snapshot to an external disk or offsite backup. If you want to have fresh backups every ten minutes, no problem.

CoW Filesystems

But what filesystem to choose? If you read much of my blog, you’ll know that I’m going to be looking at open source solutions. This boils down to three serious contenders: OpenZFS, Btrfs, and bcachefs.

OpenZFS

OpenZFS has a proven track record of reliability and is by far the most mature candidate. It also benefits from native encryption, great defaults, and a robust, unified interface. Unfortunately, its CDDL license is incompatible with the GPL license used by the Linux kernel. This has lead to the need for less-than ideal workarounds. Unless you’re on Ubuntu, FreeBSD, or NetBSD. Ubuntu ships ZFS in its own releases of the Linux kernel. Both FreeBSD and NetBSD, having a more permissive license, don’t have issues with the CDDL license.

Btrfs

Btrfs is newer but has been around for over a decade at this point. It’s suffered from reliability issues in the past and doesn’t offer native encryption. It is licensed under the GPL, however, and therefore available in the kernel of every Linux distribution. Recently, Fedora has begun shipping it as the default filesystem and openSUSE has been using it as the default since 2014.

bcachefs

bcaches is new on the block and not yet mainlined in the Linux kernel. It does, however, have a promising feature set already and might offer some powerful performance improvements over Btrfs and ZFS. Time will tell with this one.

The Choice

Currently, I have a better familiarity and understanding of ZFS. That said, its unified approached to filesystem and storage management plus extensive documentation and literature make it very accessible.[2].

As for as operating systems go, I’m only going to use one of the BSD’s or Linux wherever I have the choice. As far as desktops go, Linux has significantly more polish in this respect to the *BSD.[3] I prefer to use elementary OS as my primary, stable desktop distribution. I’m planning on also having a system running Fedora and want to use the same filesystem configuration on both. The idea of mixing filesystems seems unnecessarily complicated, though completely doable.

The prospect of vendor lock-in to Ubuntu ultimately lead me to Btrfs. I get the freedom of choice in regards to Linux distribution and only have to manage one filesystem on my machine.

Conclusion

So far, I’m pretty far into configuring my desktops with Btrfs, and I’m happy with the outcomes. The default settings had to be tweaked quite a bit and getting all of the tooling in place for snapshot and backup management has been a pain. More fodder for the blog, though.


1. Read about the comparison to rsync in the Ars Technica article rsync.net: ZFS Replication to the cloud is finally here — and it’s fast.
3. No. I’m not counting Darwin.