]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
zfs: Fix LINUX_ROOT_DEVICE when grub-probe fails master
authorDoug Goldstein <cardoe@cardoe.com>
Wed, 23 Jul 2025 15:40:04 +0000 (16:40 +0100)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 14 Aug 2025 22:27:02 +0000 (00:27 +0200)
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>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
util/grub.d/10_linux.in
util/grub.d/20_linux_xen.in

index cc393be7eda9ab79cd0207434924c06fbd27bb6d..07649cd3bd26d6a2937733cef896c72155b16dc3 100644 (file)
@@ -73,7 +73,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 94dd8be1342aaa68fd35eeede20c79b7c5e9548c..27bff00a802f2435d96e53f7aa367fcaa504ffcd 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%/}"
        ;;