This adds support for ZFS root in 10_kfreebsd.in.  It works with
current trunk if my grub-mkrelpath patch has been applied, and if
ZFS from grub-extras has been built into GRUB.
2010-07-31  Robert Millan  <r...@gnu.org>

	* util/grub.d/10_kfreebsd.in: Initialize ${kfreebsd_device} as the
	kFreeBSD device name, except on ZFS where the filesystem label is
	used.
	(kfreebsd_entry): On ZFS root, load `opensolaris.ko', `zfs.ko' and
	`/boot/zfs/zpool.cache'.
	Set mountfrom kernel variable using ${kfreebsd_device}.

=== modified file 'util/grub.d/10_kfreebsd.in'
--- util/grub.d/10_kfreebsd.in	2010-08-01 00:14:07 +0000
+++ util/grub.d/10_kfreebsd.in	2010-08-01 00:21:41 +0000
@@ -74,8 +74,27 @@ EOF
 EOF
   fi
 
+  case "${kfreebsd_fs}" in
+    zfs)
+      test -e "${module_dir}/opensolaris.ko"
+      test -e "${module_dir}/zfs.ko"
+
+      printf '%s\n' "${prepare_module_dir_cache}"
+      cat << EOF
+	kfreebsd_module_elf	${module_dir_rel}/opensolaris.ko
+	kfreebsd_module_elf	${module_dir_rel}/zfs.ko
+EOF
+
+      printf '%s\n' "${prepare_boot_cache}"
+  cat << EOF
+	kfreebsd_module		${rel_dirname}/zfs/zpool.cache type=/boot/zfs/zpool.cache
+EOF
+    ;;
+  esac
+
+
   cat << EOF
-	set kFreeBSD.vfs.root.mountfrom=${kfreebsd_fs}:${GRUB_DEVICE}
+	set kFreeBSD.vfs.root.mountfrom=${kfreebsd_fs}:${kfreebsd_device}
 	set kFreeBSD.vfs.root.mountfrom.options=rw
 }
 EOF
@@ -105,6 +124,11 @@ while [ "x$list" != "x" ] ; do
     *)                  kfreebsd_fs=${GRUB_FS} ;;
   esac
 
+  case ${GRUB_FS} in
+    zfs)		kfreebsd_device=$(grub-probe -t label --device ${GRUB_DEVICE}) ;;
+    *)			kfreebsd_device=${GRUB_DEVICE} ;;
+  esac
+
   version=`echo $basename | sed -e "s,^[^0-9]*-,,g;s/\.gz$//g"`
   alt_version=`echo $version | sed -e "s,\.old$,,g"`
 

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to