On Sat, 2012-01-28 at 13:51 +0100, Vladimir 'φ-coder/phcoder' Serbinenko
wrote:
Index: grub/util/grub.d/10_linux.in
===================================================================
--- grub.orig/util/grub.d/10_linux.in 2012-01-24 23:44:10.530591000 -0600
+++ grub/util/grub.d/10_linux.in 2012-01-24 23:44:10.706928000 -0600
@@ -56,8 +56,10 @@
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
fi
-if [ "x`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2>/dev/null ||
true`" = xbtrfs ] \
- || [ "x`stat -f --printf=%T /`" = xbtrfs ]; then
+LINUX_ROOT_FS=`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2>/dev/null
|| true`
+LINUX_ROOT_STAT=`stat -f --printf=%T / || true`
+
+if [ "x${LINUX_ROOT_FS}" = xbtrfs -o "x${LINUX_ROOT_STAT}" = xbtrfs ]; then
rootsubvol="`make_system_path_relative_to_its_root /`"
rootsubvol="${rootsubvol#/}"
if [ "x${rootsubvol}" != x ]; then
@@ -76,6 +78,10 @@
GRUB_CMDLINE_EXTRA="$GRUB_CMDLINE_EXTRA crashkernel=384M-2G:64M,2G-:128M"
fi
+if [ "x${LINUX_ROOT_FS}" = xzfs ]; then
+ GRUB_CMDLINE_LINUX="boot=zfs \$bootfs ${GRUB_CMDLINE_LINUX}"
+fi
+
linux_entry ()
{
os="$1"
@@ -114,6 +120,12 @@
fi
printf '%s\n' "${prepare_boot_cache}"
fi
+ if [ "x${LINUX_ROOT_FS}" = xzfs ]; then
+ cat<< EOF
+ insmod zfsinfo
+ zfs-bootfs (\$root) bootfs
This makes 3 wrong assumptions in a row:
- / and /boot may be different.
Despite the variable being called LINUX_ROOT_FS, this is really the
output from grub-probe --device ${GRUB_DEVICE}. When / != /boot, is
$GRUB_DEVICE the device of / or /boot?
- Linux may be in a non-root subvolume. Then the subvolid points to
wrong one.
By "Linux", you're talking about the kernel, as opposed to the root
filesystem, correct?
What do you mean by "non-root subvolume"? That sounds like a btrfs term,
not a ZFS term, so I don't follow.
- / may be unaccessible to GRUB altogether.
Are you talking about at grub-install time or boot time? Can you provide
an example of when this might happen, so I can understand.
In short: this command line part has to be generated on grub-mkconfig
time and have a stable representation. I'd recommend UUID and subvolume
name.
By "this command line part", are you talking about the path to the
kernel?