#1139182 grub-installer: Let findfs always return only one device

#1139182#5
Date:
2026-06-06 19:55:06 UTC
From:
To:
Dear maintainers,

the command

   grub-probe -t device $1

in findfs (where $1 is /target or /target/boot) returns all the devices of
a ZFS pool if it has been created from more than one device, e.g.,

   grub-probe -t device /target/boot

may return the following two lines:

/dev/sda2
/dev/sdb2

The result of findfs is then stored in $rootfs and $bootfs respectively,
but subsequent calls (to mapdevfs for instance) expect these variables to
refer to a single device only and fail otherwise.

Letting findfs always return only the first device will do.

I will send a patch as a separate e-mail for your convenience.

Thank you in advance!

Best regards,

Thomas Uhle

#1139182#10
Date:
2026-06-06 20:00:42 UTC
From:
To:
Return the first device if grub-probe returns all devices of a ZFS pool
for instance.  Closes: #1139182
---
  grub-installer | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grub-installer b/grub-installer
index 30e7ecfc..ee0b2c56 100755
--- a/grub-installer
+++ b/grub-installer
@@ -151,7 +151,7 @@
  }

  findfs () {
-	if ! grub_probe -t device $1; then
+	if ! grub_probe -t device $1 | head -n1; then
  		mount | grep "on $ROOT${1%/} " | tail -n1 | cut -d' ' -f1
  	fi
  }