zfs: fix LINUX_ROOT_DEVICE when grub-probe fails
authorDoug Goldstein <cardoe@cardoe.com>
Fri, 18 Dec 2020 02:27:14 +0000 (20:27 -0600)
committerJulian Andres Klode <jak@debian.org>
Sun, 2 Nov 2025 11:08:11 +0000 (12:08 +0100)
When grub-probe fails, the current code is to just stuff an empty result
in which causes the user to not knowingly have a system that no longer
boots. grub-probe can fail because the ZFS pool that contains the root
filesystem might have features that grub does not yet support which is a
common configuration for people with a rpool and a bpool. This behavior
uses the zdb utility to dump the same value as the filesystem label
would print.

Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
Gbp-Pq: Topic upstream
Gbp-Pq: Name zfs-fix-LINUX_ROOT_DEVICE-when-grub-probe-fails.patch

util/grub.d/10_linux.in
util/grub.d/20_linux_xen.in

index c47a8bb06fc252abb5cccc2c5bed03c4adbd2e24..268121dd6dfb1dcf7ff205ce558da91b8532d716 100644 (file)
@@ -89,7 +89,7 @@ case x"$GRUB_FS" in
            GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
        fi;;
     xzfs)
-       rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
+       rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || zdb -l ${GRUB_DEVICE} | awk -F \' '/ name/ { print $2 }'`
        bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
        LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}"
        ;;
index e73e96f81d51d6b24adca4b77a8e219e875f25cf..15597ad4b42e7f697e4870cd9197be6b58300a43 100644 (file)
@@ -81,7 +81,7 @@ case x"$GRUB_FS" in
            GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
        fi;;
     xzfs)
-       rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
+       rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || zdb -l ${GRUB_DEVICE} | awk -F \' '/ name/ { print $2 }'`
        bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
        LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}"
        ;;