I'm new to btrfs and I'd like some advice on partitioning and subvolume strategy. The system is a light-duty web server, and assume it only has a single disk.

With ext filesystems, I've always created separate partitions for /, /var, swap (and possibly /boot and /home). For me, /var always contains all valuable web server data (e.g. MySQL databases) and none of the code. That allows me to easily move the data to a different system (move or copy /var) or re-install the OS without disrupting the data (reformat /) etc.

Using btrfs, I could do the same thing, use the same partitioning scheme, and have a separate btrfs filesystem on each partition. Or, I could have a single partition, and use btrfs subvolumes for /, /var and so forth. What would be the pros and cons of that?

It seems to me there may be some advantage in having /-only and /var-only snapshots, for example ("Restore all the data to a previous checkpoint" vs "restore all the code" vs "restore both"). Is that right, or does it only appear that way?

Bonus question: are there advantages to using lvm below the btrfs filesystem(s)?

Bonus question 2: how would your advice change if the system had two disks of the same size?

Any pointers to "this is what I did and how it has worked for me" articles would also be appreciated. I can find plenty of material on what I can do, but I'm failing to find much saying "this is what I tried and this is why it worked or didn't".

  • 1
    Great question! I wanted to ask almost the same. I'd like to use raid1 and luks encryption, but it is hard to find relevant info about the basics. E.g. whether I can install an op system on a single duplicated volume and can use subvolume for /swap, etc. without any drawback. Maybe I should read the manual, but I don't like long texts. :D – inf3rno Oct 29 '17 at 11:17

If you don’t have specific needs, use btrfs as you would use another filesystem. Separating /home is a good practice.

Personally, on home servers my only subvolume is /etc, so I can make snapshots of the configurations. This can be automated with tools like snapper.

Usually, there is little interest of restoring just a previous version of /var, because of the need to also restore /lib/stuff. It is an all-or-nothing situation.

Snapshots of /home can be VERY big, so the disk size management is soon a problem. It can be done without any problem, but keep an eye on the remaining space. Also, as snapshots can only be made on the same disk, they are not a solution for backups in case of disk failure. Think of them as something for the situations like "oups, I deleted this file two hours ago, but I still need it".

Bonus 1 : none. In fact, btrfs was designed in order to simplify the stack mdadm+lvm+fs. So it is really better to avoid it.

Bonus 2 : No, but make a RAID 1! Simple and efficient, your data will love you :)

Ninja bonus : you really probably want to have a good look at the btrfs wiki.

  • btrfs support mirroring and other RAID'ish configuration. Even you should avoid to reproduce RAID6, you could easily make a mirror by simply adding a partition after the installation. You could find a nice how to here (complang.tuwien.ac.at/anton/btrfs-raid1.html) – JOduMonT Mar 10 '19 at 18:30

I've been revisiting this lately and thought I'd share a very well thought out post that proposes one partition with top-level directories containing subvolumes: https://bbs.archlinux.org/viewtopic.php?id=194491


      ├── subvol_root
      │        └── /usr, /bin, /sbin, /.snapshots, etc
      ├── subvol_snapshots
      ├── subvol_home
      └── subvol_opt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.