zfs: Fix LINUX_ROOT_DEVICE when grub-probe fails

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>
This commit is contained in:
Doug Goldstein authored and Daniel Kiper committed 2025-08-15 00:27:02 +02:00
1 parent 6898fcf74d
commit 19c698d123
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -73,7 +73,7 @@ case x"$GRUB_FS" in
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}" GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
fi;; fi;;
xzfs) 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,@$,,"`" bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}" LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}"
;; ;;
+1 -1
View File
@@ -81,7 +81,7 @@ case x"$GRUB_FS" in
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}" GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
fi;; fi;;
xzfs) 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,@$,,"`" bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}" LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}"
;; ;;