Skip to contentSkip to conversation

zfs: fix LINUX_ROOT_DEVICE when grub-probe fails

PATCH In review Doug Goldstein 2 participants 3 messages Dec 18, 2020 – Dec 23, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 util/grub.d/10_linux.in     | 2 +-
 util/grub.d/20_linux_xen.in | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
util/grub.d/10_linux.in +1 -1
index e8b01c0d0..33a25ba8f 100644
@@ -71,7 +71,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%/}"
 	;;
util/grub.d/20_linux_xen.in +1 -1
index 3b1f47049..96210c24d 100644
@@ -79,7 +79,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%/}"
 	;;
Signature · 1 line
2.24.3 (Apple Git-128)
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Doug Goldstein

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.

Daniel

#2 lore raw
In reply to Doug Goldstein
Quoted 9 lines · Doug Goldstein

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.

For an unknown reason xgettext hangs during build after this patch. Could you check what is going on?

Daniel