Holy Cow – BTRFS!

Recently I have been experimenting with BTRFS. BTRFS is a relatively new filesystem which has modern features, high performance, scalability, supporting file-system snapshots and on-the-fly compression.

After spending the week running BTRFS on Ubuntu from within a Virtualbox VM I reinstalled my laptop using it. Ubuntu’s installer supports creating btrfs partitions, which is handy, and it is reported to work even as a boot partition. I had problems using BTRFS as the boot partition however, so elected to use ext2 for boot in the real install.

The installer doesn’t support enabling the on the fly compression, so once I had the system installed I edited /etc/fstab adding “compress=lzo”, I added “ssd” as I have an SSD and “space_cache” which is reported to improve performance. After I rebooted I ran a filesystem balance to compress any existing compressible data like so:-

btrfs fi balance /
btrfs fi balance /home

It’s worth pointing out here that there still isn’t a utility which can fix BTRFS filesystem corruption, so although BTRFS is considered stable, you may want to stay away from it just in case. There is also a nasty condition that can cause a kernel crash if the file-system runs out of space, so that is another one to watch for.

Having used BTRFS for a little while and also running IOZONE tests on it via Phoronix Test Suite, I can report that under certain conditions the on the fly compression significantly increases performance, and significantly reduces the amount of space required to store things. My system partition now uses 2.8GB of space where it used 4GB with EXT4 (that could also be explained by better more efficient storage of BTRFS) and my home partition is now 25% full instead of 50%. This sort of space saving is particularly useful with SSDs where space is at a premium.

Similarly I’ve upgraded my external storage (a couple of 300GB Western Digital drives in a RAID 1 array) to use BTRFS and lzo compression, reducing space taken from 167GB to 106GB. it’s like getting an extra 50% storage free!

I did have some problems trying to use the inbuilt BTRFS raid. For some reason it would allow me to create a mirror with a suitably sized loop file but would only allow me to write 2GB of data before running out of space. I needed to create the array with one device missing as I only had 2 drives and wanted to copy existing data from the old array, so after some head banging I elected to use a good old fashioned md array, as I had been, and simply place BTRFS on top of that (seemed wise as there are some gotchas with BTRFS which need to be ironed out before BTRFS RAID is production ready IMO).

After rsyncing the data and adding the second drive into the array, it is rebuilding as I write this, but all is well as far as I can tell.

There are a couple of problems. After enabling LZO compression, balancing the filesystem and rebooting “fsck.btrfs” (which is actually a symbolic link to btrfsck) complains that there are incompatible features enabled and will not run. This causes the boot-up to hang and wait for a response. Hitting “i” to ignore completes the boot process, but if it is on a server, you obviously don’t want to be interacting with the machine (or may not even be there to). The simple workaround is to remove the symbolic link i.e.

sudo rm /sbin/fsck.btrfs

to return the boot process to normal.

Secondly any program that fsyncs a lot brings BTRFS down to a crawl, dpkg does this and so any significant install/update (even on a machine with an SSD) can be described as sluggish. To solve this problem add Brian Roger’s PPA like so:-

sudo add-apt-repository ppa:brian-rogers/btrfs

sudo apt-get update

sudo apt-get upgrade

Join the conversation


    1. So it won’t get checked at all, yep, good idea. Although Btrfschk is somewhat more functional now than it was at time of writing. Perhaps it’s a non-issue now, I don’t know.

Leave a comment