[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#595152: ZFS support



Package: grub-installer
Version: 1.55
Severity: wishlist
Tags: patch

This patch adds ZFS support to grub-installer.

Note: findfs change is required because mount output only gives zpool name,
not the device associated with it.  The other changes should be obvious.

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/2 CPU cores)
Locale: LANG=ca_AD.UTF-8, LC_CTYPE=ca_AD.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
diff -ur grub-installer-1.55.old/grub-installer grub-installer-1.55/grub-installer
--- grub-installer-1.55.old/grub-installer	2010-08-18 16:38:02.000000000 +0200
+++ grub-installer-1.55/grub-installer	2010-09-01 13:47:23.554370178 +0200
@@ -75,10 +75,15 @@
 
 serial="$(get_serial_console)"
 
+grub_probe () {
+	apt-install grub-common
+	$chroot $ROOT grub-probe $@
+}
+
 # Usage: convert os_device
 # Convert an OS device to the corresponding GRUB drive
 convert () {
-	tmp_drive="$($chroot $ROOT grub-probe -d -t drive "$1")" || exit $?
+	tmp_drive="$(grub_probe -d -t drive "$1")" || exit $?
 	if [ "$partition_offset" != 0 ]; then
 		tmp_part="$(echo "$tmp_drive" | sed 's%.*,\([0-9]*\)).*%\1%')"
 		if [ "$tmp_part" ] && [ "$tmp_part" != "$tmp_drive" ]; then
@@ -118,7 +123,7 @@
 }
 
 findfs () {
-	mount | grep "on $ROOT${1%/} " | tail -n1 | cut -d' ' -f1
+	grub_probe -t device $1
 }
 
 findfstype () {
@@ -314,6 +319,10 @@
 	# Booting from UFS requires grub2
 	grub_package="grub-pc"
 	;;
+    *:zfs:*:*)
+	# Booting from ZFS requires grub2
+	grub_package="grub-pc"
+	;;
     *:ext2fs:*:grub-pc | *:xfs:*:grub-pc)
     	# Booting ext2fs or xfs using grub2 works
         ;;
@@ -658,6 +667,11 @@
 db_progress STEP 1
 db_progress INFO grub-installer/progress/step_config_loader
 
+if [ "$bootfstype" = "zfs" ]; then
+  # Required by update-grub on ZFS
+  cp /boot/zfs/zpool.cache $ROOT/boot/zfs/
+fi
+
 # Delete for idempotency
 rm -f $ROOT/boot/grub/$menu_file
 update_grub

Reply to: