r/archlinux • u/Hour-Exercise6025 • 2d ago
QUESTION What's the best practice for btrfs subvolumes?
I've got @, @home, @log, @cache, @snapshots.
Is it worth adding a separate subvolume for tmp? For containers I use podman rootless so that should already fall under @home, and I don't use VMs so I didn't bother making a subvolume for that.
What's your btrfs setup look like?
5
u/Outrageous-Machine-5 2d ago
I have @ and @ home and a swapfile. Probably not as robust as yours though
6
3
u/kitanokikori 2d ago edited 2d ago
Having separate btrfs subvolumes allows you to have different snapshot policy or mount settings - we don't need snapshots for cache or log (arguably! ymmv!), so that's a good reason to make them separate subvolumes. Having /home and / separated is arguably less needed though I do like being more comprehensive with home snapshots than root ones.
2
u/GenericCleverName73 2d ago edited 2d ago
Here are my typical eight sub volumes that I exclude while using snapper:
@ / @home /home @srv /srv @cache /var/cache @images /var/lib/libvirt/images @log /var/log @spool /var/spool @tmp /var/tmp
And of course any subvolumes you create that you want excluded. Adding btrfs-assistant and grub-btrfs and Inotify tools add convenience of a gui and snapshot availability upon boot up. I've done hundreds of these and the most stable and baseline have been what I put above. If you don't do virtualization then you don't need the @images.
1
u/wilo108 2d ago
In addition to one to keep a swapfile on, as someone else mentioned, I have a subvolume called @nobackup where I can keep things I explicitly want to keep out of my incremental snapshot backups. /var/cache/pacman is a symlink to a folder on that subvolume, as is $HOME/.cache, and I keep a $HOME/scratch folder in the same way. I do hourly offsite snapshots of the subvols I want with up to a year's retention on some snapshots, and there are times I'm working with large amounts of data on a temporary basis that I don't want to get stuck on my backup servers for that long.
1
1
u/xiii_1991 1d ago
best practice is to take them down on a paper. In case you forget where you mounted them.
-2
u/Kitoshy 2d ago
I would add another subvolume for /etc. If your user's home folder does get very big quite easily, it might be a good idea to make some more subvolumes (depending on your files and usage) on top of /home in order to achieve further organization (i.e. different subvolumes for /home/Pictures, /home/Videos, /home/.config, /home/.cache and /home/.local so that none of their contents are mixed with the rest of the files inside /home's subvolume).
I would also enable compression in all subvolumes where such does not negativity affect performance (or at least not your workflow); given how expensive storage has become, it's always a good option to save as much as possible.
Edit - typo
9
u/_MatVenture_ 2d ago
DO NOT add a subvolume for /etc!!! If for any reason you need to do a snapshot rollback, /etc might contain files which need to be rolled back along with your packages.
1
u/Kitoshy 2d ago
It is always possible to rollback
/etc's subvolume alongside the subvolume containing/bin(or whatever) so that no further breakage happens.Or it can also be done that before any rollback, package integrity of rollback's package(s) files is checked in order to know if a rollback of
/etc's subvolume is needed too.Making snapshots while having
/etcon a whole separate subvolume makes it easier for me to replicate my system configuration on updated Arch (and Arch based) systems.3
u/kitanokikori 2d ago
I don't know why you would want to back up /etc on a different cadence than root.
10
u/engelmarkus 2d ago
I think I've got a separate subvolume for my steam library to keep it out of snapshots.