I’m learning to use Snapper with my btrfs to make snapshots of my root. Snapper is used in openSUSE and available to other linux oses too. My system is Gentoo and I’ve followed the wiki
and got it working. At the moment it makes a new snapshot everytime I update my system.
here’s the status of my system before I did first update after followed the wiki:
$ snapper list
# │ Type │ Pre # │ Date │ User │ Cleanup │ Description │ Userdata
──┼────────┼───────┼──────────────────────────────────┼──────┼─────────┼─────────────┼─────────
0 │ single │ │ │ root │ │ current │
1 │ single │ │ Thu 10 Oct 2024 08:59:47 PM EEST │ pete │ │ │
then after sync&update (there was 7 packages to update)
$ snapper list
# │ Type │ Pre # │ Date │ User │ Cleanup │ Description │ Userdata
───┼────────┼───────┼──────────────────────────────────┼──────┼─────────┼───────────────────────────────────────────────────────────────────────────────┼─────────
0 │ single │ │ │ root │ │ current │
1 │ single │ │ Thu 10 Oct 2024 08:59:47 PM EEST │ pete │ │ │
2 │ pre │ │ Fri 11 Oct 2024 10:34:15 AM EEST │ root │ number │ Upgrading to dev-lang/spidermonkey-115.16.0 replacing version(s) 115.15.0 │
3 │ post │ 2 │ Fri 11 Oct 2024 10:34:18 AM EEST │ root │ number │ Upgrading to dev-lang/spidermonkey-115.16.0 replacing version(s) 115.15.0 │
4 │ pre │ │ Fri 11 Oct 2024 10:34:29 AM EEST │ root │ number │ Upgrading to dev-libs/ell-0.69 replacing version(s) 0.66 │
5 │ post │ 4 │ Fri 11 Oct 2024 10:34:32 AM EEST │ root │ number │ Upgrading to dev-libs/ell-0.69 replacing version(s) 0.66 │
6 │ pre │ │ Fri 11 Oct 2024 10:34:34 AM EEST │ root │ number │ Upgrading to net-libs/libpsl-0.21.5 replacing version(s) 0.21.5 │
7 │ post │ 6 │ Fri 11 Oct 2024 10:34:37 AM EEST │ root │ number │ Upgrading to net-libs/libpsl-0.21.5 replacing version(s) 0.21.5 │
8 │ pre │ │ Fri 11 Oct 2024 10:35:03 AM EEST │ root │ number │ Upgrading to net-firewall/ufw-0.36.1-r1 replacing version(s) 0.36.1 │
9 │ post │ 8 │ Fri 11 Oct 2024 10:35:10 AM EEST │ root │ number │ Upgrading to net-firewall/ufw-0.36.1-r1 replacing version(s) 0.36.1 │
10 │ pre │ │ Fri 11 Oct 2024 10:35:48 AM EEST │ root │ number │ Upgrading to www-client/firefox-bin-131.0.2 replacing version(s) 131.0 │
11 │ post │ 10 │ Fri 11 Oct 2024 10:35:52 AM EEST │ root │ number │ Upgrading to www-client/firefox-bin-131.0.2 replacing version(s) 131.0 │
12 │ pre │ │ Fri 11 Oct 2024 10:36:13 AM EEST │ root │ number │ Upgrading to mail-client/thunderbird-bin-128.3.1 replacing version(s) 128.3.0 │
13 │ post │ 12 │ Fri 11 Oct 2024 10:36:17 AM EEST │ root │ number │ Upgrading to mail-client/thunderbird-bin-128.3.1 replacing version(s) 128.3.0 │
14 │ pre │ │ Fri 11 Oct 2024 10:36:29 AM EEST │ root │ number │ Upgrading to app-portage/emlop-0.7.0 replacing version(s) 0.6.1 │
15 │ post │ 14 │ Fri 11 Oct 2024 10:36:32 AM EEST │ root │ number │ Upgrading to app-portage/emlop-0.7.0 replacing version(s) 0.6.1
I think this is a bit too much to have a pre and post snapshot of every updated package. Optimal would be one snapshot before update and one snapshot after update of all packages.
Maybe I remove the /etc/portage/bashrc script (seen in the wiki link) for now and just make a scheduled snapshot for now.
This snapper thing is very cool but I need to read more about it… Do you have any tips / tricks?
That is neat.
I suppose a snapshot is a .img file? If that is the case , what grub would do is loop mount the snapshot file, so it looks like a device.
So the boot process uses /boot/grub and there is grub-brtfs.cfg which adds a boot menu item “Gentoo” where it lists all snapshots. I can choose at boot to continue normally, use Debian(dual boot) or go to the snapshot menu. The GitHub link I posted earlier has more info.
me too
here’s the start of the 41_snapshots-btrfs:
cat /etc/grub.d/41_snapshots-btrfs
#! /usr/bin/env bash
#
# Written by: Antynea
# BTC donation address: 1Lbvz244WA8xbpHek9W2Y12cakM6rDe5Rt
# Github: https://github.com/Antynea/grub-btrfs
#
# Purpose:
# Improves Grub by adding "btrfs snapshots" to the Grub menu.
# You can boot your system on a "snapshot" from the Grub menu.
# Supports manual snapshots, snapper, timeshift ...
# Warning : booting on read-only snapshots can be tricky.
# (Read about it, https://github.com/Antynea/grub-btrfs#warning-booting-on-read-only-snapshots-can-be-tricky)
#
# What this script does:
# - Automatically List snapshots existing on root partition (btrfs).
# - Automatically Detect if "/boot" is in separate partition.
# - Automatically Detect kernel, initramfs and intel/amd microcode in "/boot" directory on snapshots.
# - Automatically Create corresponding "menuentry" in grub.cfg.
# - Automatically detect the type/tags and descriptions/comments of snapper/timeshift snapshots.
# - Automatically generate grub.cfg if you use the provided systemd service.
#
# Installation:
# - Refer to https://github.com/Antynea/grub-btrfs#%EF%B8%8F-installation
#
# Customization:
# You have the possibility to modify many parameters in /etc/default/grub-btrfs/config.
# Read more here https://github.com/Antynea/grub-btrfs#installation- an in the manpage
# 'man grub-btrfs'
#
# Automatically update Grub
# If you would like grub-btrfs menu to automatically update when a snapshot is created or deleted:
# - Refer to https://github.com/Antynea/grub-btrfs#-automatically-update-grub-upon-snapshot.
#
# Special thanks for assistance and contributions:
# - My friends
# - All contributors on Github
#