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.
I noticed that this is confusing in #230, user would search for errors in
the grub-btrfs.cfg file although the old grub-btrfs.cfg file is never
overwritten with grub-btrfs.new
Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
* Make path of "grub-mkconfig_lib" configurable
* 41_snapshots-btrfs file:
- Remove "datarootdir" variable, is no longer used
- Replace "$datarootdir/grub/grub-mkconfig_lib" with "${GRUB_BTRFS_MKCONFIG_LIB:-/usr/share/grub/grub-mkconfig_lib}"
* Config file:
- Adds new GRUB_BTRFS_MKCONFIG_LIB variable
Might be '/usr/share/grub2/grub-mkconfig_lib' on some systems (Opensuse ...)
41_snapshots-btrfs file:
* Remove "grub_script_check" variable
Config file;
* Make name of "grub-script-check" configurable
* Might be 'grub2-script-check' on some systems (Fedora ...)
#### Script:
* Snapper:
- Now, the information is retrieved from the info.xml file.
* Timeshift:
* Now, the information is retrieved from the info.json file.
* Probe informations from device:
* Add the UUID of the root and boot subvolumes
* Show full path snapshot or only name:
* Remove, this feature never worked correctly
* Grub-menu:
* Now displays the following information in separate columns:
- Date of snapshot
- Path of snapshot
- Type/Tags of snapshot if available (snapper/timeshift)
- Description/Comments of snapshot if available (snapper/timeshift)
* Possibility to display only the desired information(s) (see config file)
* Adds a header for the column title
* GRUB_BTRFS_PREFIXENTRY is remove
* Boot partition detection:
* grub-btrfs is now able to detect if the boot folder/partition is a subvolume
* GRUB_BTRFS_OVERRIDE_BOOT_PARTITION_DETECTION should no longer be needed for this case
* Variables:
* Rename some variables
* Header:
* Update the header to reflect the changes.
#### Config:
* GRUB_BTRFS_PREFIXENTRY:
* Remove, no longer use
* GRUB_BTRFS_DISPLAY_PATH_SNAPSHOT:
* Remove, no longer use
* GRUB_BTRFS_TITLE_FORMAT:
* Shows/Hides "date" "snapshot" "type" "description" in the Grub menu, custom order available.
Default: ("date" "snapshot" "type" "description")
* GRUB_BTRFS_IGNORE_SNAPPER_TYPE:
* Rename to GRUB_BTRFS_IGNORE_SNAPSHOT_TYPE
- Supports both timeshift and snapper tags/type
* GRUB_BTRFS_IGNORE_SNAPPER_DESCRIPTION:
* Rename to GRUB_BTRFS_IGNORE_SNAPSHOT_DESCRIPTION
- Supports both snapper and timeshift description/comments
* GRUB_BTRFS_OVERRIDE_BOOT_PARTITION_DETECTION:
* grub-btrfs is now able to detect if the boot folder/partition is a subvolume.
Activating this parameter should no longer be necessary for this case.
* GRUB_BTRFS_SNAPPER_CONFIG:
* Remove, no longer use
#### Readme:
* Update "What does grub-btrfs v4.xx do" section
* Adds support for timeshift
* Update "GRUB_BTRFS_DISABLE_PROTECTION_SUBMENU":
* Remove default parameter (false), not needed
* adds automatic conversion of the value to lower case