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?
About this post
- Posted
- Archived
- Score
- 9 · 100% up
- Kind
- Text
- ID
- ef2flt
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.
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!
Thank you very much for checking! Last time I had to rollback, this was necessary and had me confused. Definitely a nice improvement.
I actually mount my subvols by path.
Me too, but I'm pretty sure I had trouble booting if no subvolid was set. This could have changed since the last time I tried.
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.
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.
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...
This is the scheme I am using:
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
/__snapshotswith 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/srvshould have snapshots as root/opt/home, but I don't currently have anything there. May be eventually will get rid of this subvolume.