Btrfs, the filesystem for the future

Posted by

tux-harddrive

I've had btrfs on my radar for a long time, but never prioritized it because it was said to be unstable. Not quite what you want your filesystem to be. At Linuxcon Japan 2014, Marc Merlin from Google had a talk about how he's been using btrfs on his laptop and at home for a couple of years and why you should do it too.

If you haven't heard about btrfs, it's a filesystem that Oracle started working on in 2007 and added into the kernel in 2009. Btrfs has built in compression (lzo and gzip), supports snapshoting, raid 0, 1, 5 and 6 support (although 5 and 6 still are not stable) and more built in to one filesystem.

So what practical use do these features have?
Let's start with compression. A great example where compression would be great is on the log directory. A log directory consists mainly of text files. This means that you don't need to think of compressing files after log rotation. The filesystem will do it for you! Just create a subvolume (think of them as resizeable partitions) for /var/log with compression enabled.

Snapshoting means you can save a copy of the disk state before you do anything radical like upgrading the system or an application, altering configuration or giving your friendly sysadmin a heart attack by running the command "rm -rf *" accidentally on a customer server. You can even run it every hour so you always have a snapshot of your disk if something happens. Perfect for both your desktop machine (when your kid gets his hands on your keyboard and hammers at it, deleting the blog article you've been writing on for the last couple of hours), or on a production server when a customer accidentally deletes the menu on one of their sites. Restoring data will then be as simple as mounting the latest snapshot and copying over the files to the current one.

Built in raid support on the filesystem means you don't have to play around with linux software raid + LVM if you don't have a hardware raid controller.

There's also one cool thing you can to with btrfs and that is btrfs send/receive. This feature means that you can send a volume between machines just like doing an rsync copy, but much faster. Later copies only send the diff of the new and old filesystem. Also this will go much faster than rsync because btrfs does not need to create a list of diffs first like rsync does.

So what about the alternatives? The main alternative is ZFS, but ZFS has some disadvantages. First off, it's not in the standard kernel, and because SUN created it under a license called CDDL, it will never be in it either. CDDL is not compatible with the kernel's GPL license. And for ZFS to be license compatible, Oracle (who now owns the rights after acquiring SUN) would have to change the ZFS license to GPL. Oracle has also stated officially that they will focus their linux resources on btrfs instead of ZFS on linux.

Although btrfs is not fully complete and it has it's quirks, it seems about right to start testing it out for production. Distos like opensuse is enabling btrfs as its default filesystem this year. This is a good sign for the stability of btrfs, as replacing your default filesystem is one thing you do not do too often as a distro. Chris Mason, one of the lead developers on btrfs has also started working at Facebook with btrfs. According to him Facebook is planing on deploying btrfs to their web tier. This is also a proof of the maturity if the btrfs code.

I have yet to get my fingers dirty with btrfs, but after I heard about Marc Merlin's experiences with btrfs and it's features, it's something that is back on my radar.

...And who knows, maybe there will be a follow up post on my experinces with it. ;)

For more info on btrfs, check out the following links:

Comments