Bug#848945: grub-common: Empty rpool leaves ZFS systems unbootable

наб nabijaczleweli at nabijaczleweli.xyz
Tue Mar 9 15:32:22 GMT 2021


Control: found -1 2.04-16

GRUB still runs
  /usr/sbin/grub-probe --device /dev/vdb1 /dev/vda3 /dev/vdd1 /dev/vde1 --target=fs_label
for me which writes
(started writing recently? possibly something to do with pool upgrade)
  /usr/sbin/grub-probe: error: unknown filesystem.
to the stderr and leaves me with
  LINUX_ROOT_DEVICE=ZFS=/root
which means I need to mount /sysroot manually from the dracut shell.
Suboptimal.

Here's a simple way to work around this:
-- >8 --
diff --git a/10_linux.orig b/10_linux
index b018819..086401c 100755
--- a/10_linux.orig
+++ b/10_linux
@@ -89,9 +89,8 @@ 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`
-	bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
-	LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}"
+	bootfs=`awk '$2 == "/" {print $1; exit}' /proc/mounts`
+	LINUX_ROOT_DEVICE="ZFS=${bootfs}"
 	;;
 esac
-- >8 --

And a properer way:
-- >8 --
diff --git a/10_linux.orig b/10_linux
index b018819..e8cfd71 100755
--- a/10_linux.orig
+++ b/10_linux
@@ -89,9 +89,9 @@ 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`
-	bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
-	LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}"
+	bpool=`awk '$2 == "/" {FS="/"; $0 = $1; print $1; exit}' /proc/mounts`
+	bootfs=`zpool get -Ho value bootfs ${bpool}`
+	LINUX_ROOT_DEVICE="ZFS=${bootfs}"
 	;;
 esac
-- >8 --

Or one that should work best for all cases:
-- >8 --
diff --git a/10_linux.orig b/10_linux
index b018819..600c1db 100755
--- a/10_linux.orig
+++ b/10_linux
@@ -89,9 +89,13 @@ 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`
-	bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
-	LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}"
+	mounted=`awk '$2 == "/" {print $1; exit}' /proc/mounts`
+	bpool=`echo ${mounted} | cut -d/ -f1`
+	bootfs=`zpool get -Ho value bootfs ${bpool}`
+	if [ "$bootfs" = "-" ]; then
+		bootfs="${mounted}"
+	fi
+	LINUX_ROOT_DEVICE="ZFS=${bootfs}"
 	;;
 esac
-- >8 --

Same applies to 20_linux_xen.

Please consider this vague inspiration and a thread bump.

Best,
наб
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-grub-devel/attachments/20210309/95c36759/attachment.sig>


More information about the Pkg-grub-devel mailing list