Here's a new patch.  It takes into account that filesystem
creation is stateful with ZFS (once a pool is created, it
remains "registered"), but partman expects it to be stateless.

The workaround is to export the pool inmediately after
creating it, then import it when mounting it.

-- 
Robert Millan
diff -Nurp -x changelog partman-zfs.old/check.d/zfs_root 
partman-zfs/check.d/zfs_root
--- partman-zfs.old/check.d/zfs_root    2010-09-02 14:37:52.966988000 +0200
+++ partman-zfs/check.d/zfs_root        1970-01-01 01:00:00.000000000 +0100
@@ -1,44 +0,0 @@
-#!/bin/sh
-# Check that the root partition is of type ZFS.
-
-case "$(udpkg --print-os)" in
-       "kfreebsd")
-       ;;
-       *)
-               exit 0
-       ;;
-esac
-
-. /lib/partman/lib/base.sh
-
-for dev in $DEVICES/*; do
-       [ -d "$dev" ] || continue
-       cd $dev
-       open_dialog PARTITIONS
-       while { read_line num id size type fs path name; [ "$id" ]; }; do
-               [ "$fs" != free ] || continue
-               [ -f $id/method ] || continue
-               [ -f $id/acting_filesystem ] || continue
-               [ -f $id/mountpoint ] || continue
-               mountpoint=$(cat $id/mountpoint)
-               filesystem=$(cat $id/acting_filesystem)
-               if [ "$mountpoint" = / ]; then
-                       root_fs=$filesystem
-                       root_type=$type
-                       root_path=$path
-               fi
-       done
-       close_dialog
-done
-
-# We need a root ZFS filesystem
-if [ "$root_fs" != zfs ]; then
-       db_set partman-zfs/root_not_zfs true
-       db_input critical partman-zfs/root_not_zfs || true
-       db_go || true
-       db_get partman-zfs/root_not_zfs
-       if [ "$RET" = true ]; then
-               exit 1
-       fi
-fi
-
diff -Nurp -x changelog partman-zfs.old/commit.d/format_zfs 
partman-zfs/commit.d/format_zfs
--- partman-zfs.old/commit.d/format_zfs 2010-09-02 14:37:52.887885000 +0200
+++ partman-zfs/commit.d/format_zfs     2010-10-12 14:19:57.274494104 +0200
@@ -63,11 +63,13 @@ for dev in $DEVICES/*; do
                        fi
 
                        code=0
-                       # Ensure label is quoted correctly
                        log-output -t partman --pass-stdout \
-                               mkfs.zfs ${label:+-L "$label"} \
-                                        ${reserved:+-m $reserved} \
+                               zpool create -f -m none "$(hostname)-$(basename 
$device)" \
                                         $device >/dev/null || code=$?
+                       # will import in mount.d/zfs
+                       log-output -t partman --pass-stdout \
+                               zpool export "$(hostname)-$(basename $device)" \
+                                        >/dev/null || code=$?
                        sync
                        db_progress STOP
 
diff -Nurp -x changelog partman-zfs.old/debian/control 
partman-zfs/debian/control
--- partman-zfs.old/debian/control      2010-09-02 14:37:53.748294000 +0200
+++ partman-zfs/debian/control  2010-09-03 22:07:45.787581939 +0200
@@ -9,6 +9,6 @@ Vcs-Svn: svn://svn.debian.org/d-i/trunk/
 Package: partman-zfs
 XC-Package-Type: udeb
 Architecture: all
-Depends: ${misc:Depends}, zfsutils-udeb, zfs-modules, partman-basicfilesystems 
(>= 59), partman-base (>= 124)
+Depends: ${misc:Depends}, zfsutils-udeb (>= 8.1-4), zfs-modules, 
partman-basicfilesystems (>= 59), partman-base (>= 124)
 Provides: partman-filesystem
 Description: Add to partman support for ZFS
diff -Nurp -x changelog partman-zfs.old/debian/partman-zfs.templates 
partman-zfs/debian/partman-zfs.templates
--- partman-zfs.old/debian/partman-zfs.templates        2010-09-02 
14:37:53.509041000 +0200
+++ partman-zfs/debian/partman-zfs.templates    2010-09-03 22:07:45.793583540 
+0200
@@ -4,18 +4,6 @@ Type: text
 # File system name (untranslatable in many languages)
 _Description: zfs
 
-Template: partman/filesystem_long/freebsd-zfs
-Type: text
-# :sl3:
-# File system name
-_Description: ZFS file system
-
-Template: partman/filesystem_short/freebsd-zfs
-Type: text
-# :sl3:
-# Short file system name (untranslatable in many languages)
-_Description: zfs
-
 Template: partman/filesystem_short/zfs
 Type: text
 # :sl3:
@@ -27,15 +15,3 @@ Type: text
 # :sl3:
 # File system name
 _Description: ZFS file system
-
-Template: partman-zfs/root_not_zfs
-Type: boolean
-# :sl3:
-_Description: Go back to the menu and correct this problem?
- Your root partition has not been configured with the ZFS file
- system. This is needed by your machine in order to boot. Please go
- back and use ZFS file system.
- .
- If you do not go back to the partitioning menu and correct this error,
- the partition will be used as is.  This means that you may not be able
- to boot from your hard disk.
diff -Nurp -x changelog partman-zfs.old/fstab.d/zfs partman-zfs/fstab.d/zfs
--- partman-zfs.old/fstab.d/zfs 2010-09-02 14:37:53.074038000 +0200
+++ partman-zfs/fstab.d/zfs     2010-09-04 01:41:13.444628012 +0200
@@ -24,15 +24,7 @@ for dev in $DEVICES/*; do
                        if [ "$options" = defaults ]; then
                                options="rw"
                        fi
-                       if [ "$mountpoint" = / ]; then
-                               if ! echo "$options" | grep -q 
'\(^\|,\)r\(o\|w\)\(,\|$\)' ; then
-                                       options="${options},rw"
-                               fi
-                               pass=1
-                       else
-                               pass=2
-                       fi
-                       echo "$path" "$mountpoint" zfs $options 0 $pass
+                       echo "$(hostname)-$(basename $path)" "$mountpoint" zfs 
$options 0 0
                        ;;
                esac
        done
diff -Nurp -x changelog partman-zfs.old/mount.d/zfs partman-zfs/mount.d/zfs
--- partman-zfs.old/mount.d/zfs 2010-09-02 14:37:53.415994000 +0200
+++ partman-zfs/mount.d/zfs     2010-10-12 14:23:36.118500815 +0200
@@ -11,8 +11,9 @@ pass=$6
 
 case $type in
     zfs)
-       mount  ${type:+-t "$type"} ${options:+-o "$options"} $fs /target$mp || 
exit 1
-       echo "umount /target$mp"
+       zpool import -f $fs || exit 1
+       zfs set mountpoint=/target${mp%/} $fs || exit 1
+       echo "zpool export $fs"
        exit 0
        ;;
 esac
diff -Nurp -x changelog partman-zfs.old/parted_names/zfs 
partman-zfs/parted_names/zfs
--- partman-zfs.old/parted_names/zfs    2010-09-02 14:37:52.795790000 +0200
+++ partman-zfs/parted_names/zfs        2010-09-03 22:07:45.793583540 +0200
@@ -1 +1 @@
-freebsd-zfs
+zfs
diff -Nurp -x changelog partman-zfs.old/valid_filesystems/zfs 
partman-zfs/valid_filesystems/zfs
--- partman-zfs.old/valid_filesystems/zfs       2010-09-02 14:37:53.289811000 
+0200
+++ partman-zfs/valid_filesystems/zfs   2010-09-03 22:07:45.793583540 +0200
@@ -15,7 +15,7 @@ case $property in
        fs=$(cat $id/detected_filesystem)
 
        case "$fs" in
-           freebsd-zfs|zfs)
+           zfs)
                echo zfs
                ;;
        esac

Reply via email to