The "Detecting snapshots ..." message was still a bare printf and bypassed the logging helpers added in #435.
Use print_info so it carries the "grub-btrfs:" prefix;
the trailing newline is handled by the helper.
Fedora uses non-standard paths and command names for GRUB (e.g., /boot/grub2 instead of /boot/grub, and grub2-mkconfig).
This change adds a conditional block to detect Fedora via /etc/fedora-release and automatically sets the appropriate variables, improving the out-of-the-box experience for Fedora users.
Two hard failures prevented 41-snapshots-btrfs from generating a
snapshot submenu when the root LUKS header is detached and cryptdevice=
uses a /dev/disk/by-id path:
* grub-probe --target=fs_uuid aborted on detached headers.
* grep-based extraction of UUID from GRUB_CMDLINE_LINUX_DEFAULT failed
when cryptdevice= did not contain “UUID=…”.
This patch:
1. Wraps grub-probe in a try/blkid/lsblk cascade that always returns the
filesystem UUID or prints a clear error.
2. Replaces the fixed “cryptomount -u $(grep …UUID=…)” line with logic
that:
• accepts both UUID=… and /dev/disk/by-id/… syntaxes,
• resolves paths to a canonical UUID with blkid,
• emits ‘cryptomount -u <uuid>’ when possible,
• falls back to ‘cryptomount -a’ only if no UUID can be extracted.
3. Keeps the previous behavior unchanged for unencrypted systems or for
installations that already worked.
Result: snapshot menu is produced and boots correctly on standard
(setup with inline header), detached-header, and by-id configurations;
no regression for existing users.
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.