Package: cryptsetup

I use Ubuntu, not Debian, and filed this bug:
https://bugs.launchpad.net/ubuntu/+source/cryptsetup/+bug/1612906

It was suggested there that I look at Debian bug #820888, titled
cryptsetup: initramfs cryptroot zfs support:
https://bugs.debian.org/820888

I think that's a separate issue, but I'm not 100% sure. Either way, it'd
be nice to upstream the patch below into Debian's cryptsetup, if the
patch is in fact suitable for Debian.

On to the actual issue...

This happens on Ubuntu 16.04:
$ sudo update-initramfs -c -k all
update-initramfs: Generating /boot/initrd.img-4.4.0-34-generic
cryptsetup: WARNING: could not determine root device from /etc/fstab
update-initramfs: Generating /boot/initrd.img-4.4.0-31-generic
cryptsetup: WARNING: could not determine root device from /etc/fstab

The attached patch adds ZFS support to cryptsetup.

-- 
Richard
diff -Nru cryptsetup-1.7.2/debian/changelog cryptsetup-1.7.2/debian/changelog
--- cryptsetup-1.7.2/debian/changelog   2016-07-01 03:57:14.000000000 -0500
+++ cryptsetup-1.7.2/debian/changelog   2016-08-03 11:35:40.000000000 -0500
@@ -1,3 +1,9 @@
+cryptsetup (2:1.7.2-0ubuntu2~rlaager1) yakkety; urgency=medium
+
+  * Support ZFS in the cryptroot initramfs-tools hook.
+
+ -- Richard Laager <rlaa...@wiktel.com>  Wed, 03 Aug 2016 11:30:29 -0500
+
 cryptsetup (2:1.7.2-0ubuntu1) yakkety; urgency=medium
 
   * New upstream release, merge from Debian unstable (LP: #1548137). Remaining
diff -Nru cryptsetup-1.7.2/debian/initramfs/cryptroot-hook 
cryptsetup-1.7.2/debian/initramfs/cryptroot-hook
--- cryptsetup-1.7.2/debian/initramfs/cryptroot-hook    2016-04-29 
01:18:05.000000000 -0500
+++ cryptsetup-1.7.2/debian/initramfs/cryptroot-hook    2016-08-03 
11:35:57.000000000 -0500
@@ -20,11 +20,7 @@
        local device mount type options dump pass
        local wantmount="$1"
 
-       if [ ! -r /etc/fstab ]; then
-               return 1
-       fi
-
-       grep -s '^[^#]' /etc/fstab | \
+       grep -s '^[^#]' /etc/fstab 2>/dev/null | \
        while read device mount type options dump pass; do
                if [ "$mount" = "$wantmount" ]; then
                        local devices
@@ -39,6 +35,21 @@
                        return
                fi
        done
+
+       zfs list -H -o name,canmount,mountpoint 2>/dev/null | \
+       while read name canmount mountpoint; do
+               [ "$canmount" = off ] && continue
+               if [ "$mountpoint" = "$wantmount" ]; then
+                       local devices
+                       for dev in $(zpool status -P "${name%%/*}" 2>/dev/null 
| awk '($1 ~ /\//) {print $1}'); do
+                               devices="$devices $(canonical_device "$dev")"
+                       done
+                       echo "$devices"
+                       return
+               fi
+       done
+
+       return 1
 }
 
 get_resume_devices() {

Reply via email to