From ece8d8715125cd7f7bf12d82527fb15982b9d105 Mon Sep 17 00:00:00 2001 From: Dorian Stoll Date: Sun, 10 Mar 2024 10:48:42 +0100 Subject: [PATCH] Add support for GRUB patches from SUSE Some GRUBs out there (Fedora, openSUSE) have an option that makes all paths relative to the default subvolume of the filesystem. This can be used to include /boot in your snapshots and roll them back without having to regenerate grub.cfg. However, enabling that option will break grub-btrfs, because loading the kernel from a different snapshot requires the paths to be absolute. To make this work, GRUB has to be told explicitly to access the root subvolume when booting to a snapshot. --- 41_snapshots-btrfs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index e1e183b..e1a8e14 100755 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -224,7 +224,12 @@ make_menu_entries() search --no-floppy --fs-uuid --set=root ${boot_hs} ${boot_uuid} else search --no-floppy --fs-uuid --set=root ${boot_uuid} + fi" + if [ "${SUSE_BTRFS_SNAPSHOT_BOOTING:-"false"}" = "true" ]; then + entry "\ + set btrfs_subvolid=5" fi + entry "\ echo 'Loading Snapshot: "${snap_date_trim}" "${snap_dir_name_trim}"' echo 'Loading Kernel: "${k}" ...' linux \"${boot_dir_root_grub}/"${k}"\" root="${LINUX_ROOT_DEVICE}" ${kernel_parameters} ${rootflags}subvol=\""${snap_dir_name_trim}"\"" @@ -259,7 +264,12 @@ make_menu_entries() search --no-floppy --fs-uuid --set=root ${boot_hs} ${boot_uuid} else search --no-floppy --fs-uuid --set=root ${boot_uuid} + fi" + if [ "${SUSE_BTRFS_SNAPSHOT_BOOTING:-"false"}" = "true" ]; then + entry "\ + set btrfs_subvolid=5" fi + entry "\ echo 'Loading Snapshot: "${snap_date_trim}" "${snap_dir_name_trim}"' echo 'Loading Kernel: "${k}" ...' linux \"${boot_dir_root_grub}/"${k}"\" root="${LINUX_ROOT_DEVICE}" ${kernel_parameters} ${rootflags}subvol=\""${snap_dir_name_trim}"\""