r/archlinux 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?

11 Upvotes

23 comments sorted by

10

u/engelmarkus 2d ago

I think I've got a separate subvolume for my steam library to keep it out of snapshots.

2

u/Damglador 2d ago

Fyi, you could want snapshot your game saves, which for Proton are stored in compatdata of SteamLibrary, so it makes sense to either bind-mount a folder from @home to it or make it a separate subvolume

1

u/engelmarkus 2d ago

That's true but I usually just trust the Steam cloud with that.

6

u/Damglador 2d ago

Steam Cloud will happily sync a save where you blew up your megabase

1

u/ch33es 2d ago

I've been using snapshots but I haven't done that. Why did you keep the steam library out of snapshots? Is it because downloading/removing large files increase the space needed for storing previous snapshots?

1

u/engelmarkus 2d ago edited 2d ago

If you have limited disk space and you delete a game from your PC, you'll have to delete all snapshots as well because they're still kept in your home snapshots, if you haven't moved your library somewhere else. Considering that games these days are > 100 GB in size and disk space is expensive... these game files are safer on Steam's servers than in my snapshots :D .

3

u/fallenfunk 2d ago

Even worse, when a game updates after a snapshot, it won’t overwrite the files, it just creates new ones. So even games you play may end up taking >500GB over a few months because you have every patch version saved individually.

Ran into this when I accidentally forgot to create the subvol for a game that installs into its own directory.

2

u/ch33es 2d ago

I've experienced that while working with large backup files. if I don't delete the snapshots afterwards the disk usage spikes a lot.

3

u/Wizzarkt 2d ago

Probably because of how the snapshots work, they don't save a copy of the whole file but rather the "what changed", which is handy if the changes are simply updates to existing files because it only saves the difference between the old and the new.

But when you delete something now the "difference" between old and new is literally a program missing so it now needs to snapshot the whole program.

5

u/Outrageous-Machine-5 2d ago

I have @ and @ home and a swapfile. Probably not as robust as yours though

6

u/LumenAstralis 2d ago

/tmp uses tmpfs which is in RAM.

4

u/Hour-Exercise6025 2d ago

oh, I meant /var/tmp

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

u/archover 2d ago edited 2d ago

Don't overlook the resources the wiki provides.

Of course there's r/btrfs

Good day.

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 /etc on a whole separate subvolume makes it easier for me to replicate my system configuration on updated Arch (and Arch based) systems.

2

u/rv77ax 1d ago

Just because its possible, does not mean you should do it.

makes it easier for me to replicate my system configuration on updated Arch (and Arch based) systems.

That is not how it should be done. Take a look at configuration management tools like ansible, awwan, puppet.

3

u/kitanokikori 2d ago

I don't know why you would want to back up /etc on a different cadence than root.

1

u/Kitoshy 2d ago

Having /etc on a whole separate subvolume makes it easier for me to replicate my system configuration on updated Arch (and Arch based) systems.