Gentoo on BTRFS

… or any other recent enough Linux distro for that matter…

Been reading a bit about BTRFS and how it’s one of the most advanced file systems out there and how it’s been in development for quite some time and yet it’s still not production ready (some say it is, others say it is not, others … like Suse … use it as the fs for the root partition and then later on stop using it for that …) and how it’s all free – unlike ZFS with its crappy GPL unfriendly license – and how CentOS is dropping it and replacing it with yet another crappy solution (what do you expect from RedHat ?), etc etc and all sorts of crap like that and I decided to simply use it as the root file system on a bunch of my nodes to put it to the test … the Cristian test … and see if it has what it takes

After reading about ways to install your OS on it, the simplest and most rewarding option for me was the convert way of doing it.

Did I hear a “wtf is that?” from the audience?

Apparently btrfs can “convert” your ext2/3/4 & reiserfs file systems to btrfs and considering not that many distros come with the ability to be installed directly on it I figured I might as well give that a try.

Step1: I prepared a Gentoo VM running on ext4 (plan being to use it a template for other VMs later on)

Step2: Install the btrfs-tools package and install grub afterwards so that it can detet it and add that sweet btrfs module to its list of supported filesystems for the boot partition.

Step3: Boot the VM using the iso (same iso used to install it) – because one cannot convert to btrfs while fs is mounted as ext …

Step4: Don’t mount the partitions, simply run btrfs-convert /dev/vda4 (replace with whatever partition you installed the os on, vda4 in my case also vda2 which was the /boot partition)

Step5: After converting all your partitions to btrfs , mount them in the correct directory structure so that you can chroot inside then from inside the chroot look at blkid and update your /etc/fstab file with correct UUIDs (that’s how I do it, stopped using device names a while ago) also replace ext2/3/4/reiserfs with btrfs (no need to change other options). In my case I also had to run grub-mkconfig to regenerate the grug.cfg file to include the insmod btrfs which was not there by default nor would it have gotten there without me installnig the btrfs-tools and recompiling grub after that to make grub add that support in.

Last step: Boot the VM the normal way and enjoy

To my surprise the damn thing booted and everything worked ok but there was however one optional last step (given btrfs’s reputation it makes sense) which was to delete the snapshot that was created during the conversion process. (when converting, having a snapshot with the old filesystem in place helps if you want to rollback to how things were).

One thing to note here is that when I tried to convert to btrfs I ran into some problems originally because I booted the VM using an older iso I had arround which was running an older kernel and btrfs-tools … as soon as I repeated the operation using a more recent iso everything worked flawless -> which to me is a form of confirmation that btrfs is now better compared to < 1 year ago.

I’m going to bet my life on it but I will most surely test the f*ck out of it before I end up using it in “production” (on my workstation for example or for hosting my personal website or email, etc)

Some light reading for the curious:

https://wiki.gentoo.org/wiki/Btrfs/Native_System_Root_Guide

https://wiki.gentoo.org/wiki/Btrfs/System_Root_Guide

Enjoy!

PS. Oh, will most surely try this operation on a few more operating systems to see how good / bad it goes and will share later on …


Posted

in

,

by

Tags: