Snapper's rollbacks work fine in Arch after a few tweaks:
- Install
snapper
,grub-btrfs
,snap-pac
; - Enable
grub-btrfsd.service
; - Add the hook
grub-btrfs-overlayfs
at the end ofHOOKS
in/etc/mkinitcpio.conf
; - Remove the
subvol=...
option from root's fstab entry; - Remove code that adds
rootflags=subvol=...
from/etc/grub.d/10_linux
; - Rebuild the grub configuration with
sudo grub-mkconfig -o /boot/grub/grub.cfg
; - Take a snapshot with
snapper create
; - Rollback to the just created snapshot with
snapper --ambit classic rollback <id>
; - Reboot.
Snapper will no longer require an `--ambit'.
Here is how I changed my /etc/grub.d/10_linux
to handle both Arch and Snapper rollbacks:
--- 10_linux.bak 2024-03-17 02:09:18.000000000 +0700
+++ 10_linux 2024-08-15 17:27:50.336843993 +0700
@@ -69,7 +69,8 @@
xbtrfs)
rootsubvol="`make_system_path_relative_to_its_root /`"
rootsubvol="${rootsubvol#/}"
- if [ "x${rootsubvol}" != x ]; then
+ # Use default subvolume in case of snapper's rollback is used
+ if [ "x${rootsubvol}" != x ] && [ "x$(btrfs subvolume get-default / | cut -d' ' -f2)" == x5 ]; then
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
fi;;
xzfs)
Pacman hook to backup kernels and modules /etc/pacman.d/hooks/zx-kernel-backup.hook
:
[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Path
Target = usr/lib/modules/*/vmlinuz
[Action]
Depends = rsync
Description = Backing up /boot and /lib/modules...
When = PostTransaction
Exec = /usr/bin/rsync -a -u --delete --exclude=.old /boot /usr/lib/modules /.kernel_backup/