First steps with BtrFS#
After using ZFS on Sun Solaris, I missed the ZFS features on Linux and with no chance of ZFS coming to Linux, I had to do with MD and LVM. Or at least until BtrFS became mature enough and since the Linux 3.0 that time slowly has come. With Linux 3.0 BtrFS supports auto defragmentation and scrubbing of volumes. The second is maybe the most important feature of both ZFS and BtrFS as it can be used to actively scan data on a disk for errors.
The first tests with BtrFS were in a virtual machine already a long time ago, but the userland tools were still in development. Now the command btrfs follow the path set by Sun Microsystems and basically combines the commands zfs and zpool for ZFS. But nothing compares to a test in the real world and so I broke a mirror and created a BtrFS volume with the name datavol:
$ sudo mkfs.btrfs -L 'datavol' /dev/sdb2
Now we can mount the volume and create a subvolume on it which we are going to be using as our new home volume for users’ home directories.
$ sudo mount /dev/sdb2 /mnt $ sudo btrfs subvolume create /mnt/home $ sudo umount /dev/sdb2
When updating /etc/fstab we can tell the command
mount to use the volume name instead of a physical path to a device or some obscure UUID number. Also, you can tell which subvolume you want to mount.
LABEL=datavol /home btrfs defaults,subvol=home 0 0
After unmounting and disabling the original volume for /home we can mount everything and copy all the data with rsync for example to see how BtrFS is working in the real world.
$ sudo mount -a
As hinted before scrubbing is important as you can verify that all your data and metadata on disk are still correct. You can do a read-write test by default or only read the test to see if all data can be accessed. There is even an option to read parts of the volume that are still unused. In the example below the subvolume for /home is being scrubbed with success.
$ sudo btrfs scrub status /home scrub status for afed6685-315d-4c4d-bac2-865388b28fd2 scrub started at Sat Jan 17 15:11:58 2012, running for 106 seconds total bytes scrubbed: 5.77GB with 0 errors ... $ sudo btrfs scrub status /mnt scrub status for afed6685-315d-4c4d-bac2-865388b28fd2 scrub started at Sat Jan 17 15:11:58 2012 and finished after 11125 seconds total bytes scrubbed: 792.82GB with 0 errors
The first glances of BtrFS in the real world are a lot better with kernel 3.1 than somewhere with kernel 2.6.30 and I’m slowly starting to say it becomes ready to be included in RHEL 7 of Debian 8 for example as a default storage solution. The same as ZFS became in Solaris 11. But it is not all glory as still a lot of work needs to be done.
The first is encryption as the LUKS era ends with BtrFS as it is not smart to put it between your disks and BtrFS. You lose the advantage of balancing data between disks when you do mirroring for example. But then again LVM has the same issue where you then also first need to set up software raid with MD with LUKS on top of it and LVM on top of that. For home directories, EncFS may be an option, but it still leaves a lot of areas uncovered that would be covered by LUKS out of the box.
The second issue is the integration of BtrFS in distributions and the handling of snapshots. As for now you first need to mount the volume before you can make a snapshot of a subvolume. The same for accessing a snapshot and for that I think ZFS still has an advantage with the
.zfs directory accessible for everyone who has access to the filesystem. But time will tell and for now, the first tests look great.