Sunday, December 11, 2011

btrfs and virtualization

Btrfs - it 's the new and feature-rich filesystem which should be eventually the next standard fs in the linux world. So long it's still in development, but it's already in the linux kernel. That's why i also gave it a try, especially for virtualization.

The feature which i'm most locking forward is snapshots. Making backups of running guests is always a cool thing :) After months of running guests on btrfs i can say I'm both exited and also a bit disappointed of btrfs.

First of all: The default settings in qemu makes the guest extremely slow. I tell you why. Usually if you start a guest, his drive cache settings are set to "writethrough". This setting controls how the host cache is used to access block data. You can choose between between "none", "writeback", "unsafe" and "writethrough" with the last one being the default.
On btrfs this makes the guest extremly slow. I made some benchmarks on lvm, ext4 and btrfs comparing "writeback", "writethrough" and "none". It's a simple comparison of how long it takes to compile dev-vcs/git with the different settings on the different filesystems:

  writeback  merge time: 1 minute and 39 seconds. 
  writethrough merge time: 1 minute and 50 seconds.
  none   merge time: 1 minute and 44 seconds.

  writeback  merge time: 1 minute and 39 seconds.
  writethrough merge time: 1 minute and 55 seconds.
  none    merge time: 1 minute and 46 seconds.

  writeback  merge time: 1 minute and 41 seconds. 
  writethrough merge time: 2 minutes and 37 seconds.
  none    merge time: 1 minute and 48 seconds.

As you can see on btrfs the compilation almost doubles the compilation time with "writethrough". Luckily, that problem is already known and at least for me it's a reason not using btrfs for virtualization.

Another downside is that btrfs still doesn't has a fsck like tool. I've used btrfs for some months now and one of my windows7 guests got corrupted. Gladly it was just a test-system. Anyway i had to delete it and made a new installation.
On the other side, the snapshot feature is really nice. I've wrote a easy backup script for the image files which worked really good.

Right now i moved all my guests to lvm (again) because i think it has still the best performance, even though i need much more space. But at least it's also possible to create live backups.

No comments:

Post a Comment