Arch Linux + BTRFS + VPS

I recently decided to give btrfs a try - not for any good reason, really. I decided to use Arch as the distribution, as it seemed to be the distro with the best support out of the box.

The installation guide left questions with me, and I ended up scouring the internet quite a bit (Google, irc, Arch wiki, forums, etc) and finally got a bootable machine today.

Here’s a quick note to any other adventurers trying out a full disk btrfs machine with Arch.

Follow the basic installation instructions for Arch until you hit the ‘Partition Disks’ step. At this point, you’ll want to do the following:

Delete all existing partitions on the drive

[root@archiso ~]# gdisk /dev/sda

At this point, use gdisk to delete any existing partions. This will, of course, cause the removal of any data from this device.

We will be using a full-disk btrfs installation, having any other partitions will cause problems with grub-install later.

Make the entire disk a btrfs filesystem

[root@archiso ~]# mkfs.btrfs /dev/sda

If any partitions remained on /dev/sda, you may need to pass the --force flag.

This allows grub-install to place itself in the 64k buffer btrfs leaves for boot loader occupation.

Create some subvolumes

[root@archiso ~]# mount -t btrfs -o defaults,compress=lzo /dev/sda /mnt
[root@archiso ~]# cd /mnt
[root@archiso mnt]# btrfs subvolume create @
[root@archiso mnt]# cd @
[root@archiso @]# btrfs subvolume create home
[root@archiso @]# btrfs subvolume create var
[root@archiso @]# btrfs subvolume create usr
[root@archiso @]# cd ..
[root@archiso mnt]# btrfs subvolume create _snapshots
[root@archiso mnt]# cd
[root@archiso ~]# umount /mnt

This creates a root container, “@”, and subvolumes for home, var, and usr. Subvolumes in btrfs should be conceptualized as akin to partitions. The ‘_snapshots’ subvolume will be used to collect snapshots of the other subvolumes.

Verify the subvolumes we just created

[root@archiso ~]# mount -t btrfs -o subvol=@,defaults,compress=lzo /dev/sda /mnt
[root@archiso ~]# ls /mnt

The result should show the three subvolumes we created earlier, home, usr, and var.

Awesome! At this point, we can continue with the installation guide, picking up after the “Mount the partitions” step. Note - Use all of the flags that you want the volumes mounted with when mounting to /mnt - genfstab uses this information.

The next place we need to do things a bit differently is…

Install and configure a boot loader

sh-4.2# grub-install --target=i386-pc /dev/sda
sh-4.2# grub-mkconfig -o /boot/grub/grub.cfg

This is the magic recipe to make the system bootable! It took quite a few different combinations of grub configuration, GPT configuration, and mkinitcpio before I found this simple solution. At this point, the installation guide can be picked back up and followed to completion!

References

  • This guide got me pretty close to success. So I thank them for posting the info!
  • Though it didn’t prove necessary, this wiki page also proved quite helpful.
  • Here is some more general reading on btrfs use cases.