Skip to content

How to handle snapper snapshots for subvolumes on btrfs?

Hi guys,

Hopefully an expert can help me out here with some advice.

Currently I have a btrfs root subvol (ID = 5), it has the following subvolumes:

@root (ID = 257) mounted to /
@home (ID = 258) mounted to /home
@snapshots (ID = 378) mounted to /.snapshots

I can use snapper to create snapshots of my / and they get stored in /.snapshots.

If I ever need to rollback my system, my plan is to boot from the live cd and do something like this:

cd /mnt
mv @root @root.broken
btrfs subvol snapshot /mnt/@snapshots/46/snapshot /mnt/@root

Seems all fine (I think, let me know if anything here sounds stupid/wrong).

Now I also have my @home subvol which I'd like to create snapshots for, and I'm trying to decide where to put them.

So far I've considered:

  • A new subvol in my btrfs root called @homesnapshots mounted to /home/.snapshots
  • A nested subvolume inside my @home (ID = 258) at /home/.snapshots

I'm also now realizing that having @snapshots as a subvol under the btrfs root subvol was probably unnecessary. I could've just put it at /.snapshots as a nested subvol of @root and if I need to do a restore I could mount it manually with its subvol ID. This would then create some consistency and I could have home's snapshots as a nested subvol at /home/.snapshots as well.

Thoughts?

9 points11 comments
Open on Reddit
About this post
Posted
Archived
Score
9 · 100% up
Kind
Text
ID
ef2flt

Author

1
posts
69
comments
0
media
View profile

11 comments

I have a similar layout as you, with .snapshots directory under root. I keep all snapshots there, for root and home.

Also remember that in case of rollback you would need to change the subvolid in your fstab, as an additional step to your instructions.

1 points

Also remember that in case of rollback you would need to change the subvolid in your fstab

This definitely was required, but I just checked https://wiki.archlinux.org/index.php/Btrfs#Mounting_subvolumes page and it says "using subvol or subvolid flags". Going to check this today, since it simplifies recovery instructions a lot.

P.S. Checked and it worked. Dropped on subvolid values from my fstab - looks much cleaner now!

3 points

Thank you very much for checking! Last time I had to rollback, this was necessary and had me confused. Definitely a nice improvement.

2 points

Frankly, I never figured out how to properly manage snapshots on BTRFS and I did try for like a year or two.

There was a way I found to make snapshots reliably and it looked very similar to your setup, but I wasn't able to get restoring from those snapshots to be reasonably easy.

1 points

I'm actually about to give up now because it turns out the latest Linux kernels are all broken in terms of btrfs. If you store your snapshots under /.snapshots then df starts to report 100% space used (it counts each snapshot as a full copy of your filesystem) as soon as you have a few snapshots. It's completely retarded and I'm actually angry that such a bug has remained in multiple kernel versions and when I went to have a chat with the #btrfs guys on freenode the consensus seems to be that btrfs is totally fucked with several other serious bugs for several kernel versions and nothing newer than 5.1 should be used. When your filesystem writes off the past 6 months of the Linux kernel as unusable I think it's time to consider it unfit for any type of production usage. Big shame because I really liked the idea of btrfs and now I'm going to have to reformat this drive.

1 points

My experience of a few years with full BTRFS has been really good, it is a shame it doesn't fit your needs. But I understand that the fact that even the devs don't seem to trust their own creation can be concerning...

1 points

This is the scheme I am using:

/__current                  -> dir
/__current/root             -> subvolume; mounted as /
/__current/var              -> dir
/__current/srv              -> subvolume; mounted as /srv
/__current/root/var/cache   -> subvolume; mounted as /var/cache
/__current/root/var/log     -> subvolume; mounted as /var/log
/__current/root/var/spool   -> subvolume; mounted as /var/spool
/__current/root/var/tmp     -> subvolume; mounted as /var/tmp
/__current/home             -> subvolume; mounted as /home
/__current/opt              -> subvolume; mounted as /opt
/__snapshots                -> dir
/__snapshots/root           -> subvolume; mounted as /.snapshots; root snapshots here
/__snapshots/home           -> subvolume; mounted as /home/.snapshots; home snapshots here
/__snapshots/opt            -> subvolume; mounted as /opt/.snapshots; opt snapshots here

Using this for a while and get used to it. Separate subvolumes for /var/<stuff> created to exclude their content from the root subvolume.

I also have btrbk service running, which replicates /__snapshots with selected backups to the nas, so I can recover the whole machine by restoring remote snapshots. Used to do it often with kernels 4.15-4.20, since btrfs used to get damaged pretty easily, but recently don't have any stability issues with it.

P.S. Technically __current/srv should have snapshots as root/opt/home, but I don't currently have anything there. May be eventually will get rid of this subvolume.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.