Categories
Internet, Unix en security

First steps with BtrFS

After using ZFS on 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 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 combine 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 user’s home directories.

$ sudo mount /dev/sdb2 /mnt
$ sudo btrfs subvolume create /mnt/home
$ sudo umount /dev/sdb2

When updating /etc/fstab we can tell 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 and 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 then 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 access 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.

Categories
Internet, Unix en security

GNOME, MD en DeviceKit

Met de introductie van DeviceKit werden dingen zoals notificatie van defecten aan harddisks ineens mogelijk geworden. Hardware werd toegankelijk voor userland zonder smerige hacks of setuid executables. Voorzieningen om deze notificaties weer te geven werden onderdeel van GNOME bij release 2.28.

Alleen wanneer zie je die notificaties? Achter deze vraag ben ik recentelijk gekomen, want hoewel de RAID weer in orde was besloot een disk om toch een paar extra herallocaties van sectoren. MD besloot om de disk weer uit de RAID-set te gooien en DeviceKit zag dat de threshold van de leverancier voor deze disk werd overschreden. Zolang de disk zichtbaar is blijft de waarschuwing zichtbaar voor de gebruiker tenzij hij of zij deze notificatie uitzet.

Gebruikers krijgen tegenwoordig tijdig een waarschuwing als er structurele fouten optreden en geeft ze een kans om preventief aan de slag te gaan. Zeker met veel disken die je gewoon kan laten omruilen als ze binnen de garantieperiode zitten. Sommige mensen kiezen daar blijkbaar niet voor, maar daar heb ik aan het einde van de dag ook geen medelijden meer mee.

Hoewel de data op de disk was geencrypt met LUKS loopt er nu toch een wipe sessie om de disk een aantal keer te overschrijven met random data. Hierna kan deze terug naar de leverancier en is het wachten op een nieuwe. Dit heeft me ook aan het denken gezet of er plugins voor Nagios zijn of dat ze nog geschreven moeten worden.