patch for finding zfs, solves: cryptsetup: WARNING: Couldn't determine root device

Bug #1830110 reported by dreamcat4
62
This bug affects 11 people
Affects Status Importance Assigned to Milestone
cryptsetup (Debian)
New
Unknown
cryptsetup (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Hi there,

There is a missing functionality in the following file: /usr/share/initramfs-tools/hooks/cryptroot

resulting in the following error message:

cryptsetup: ERROR: Couldn't resolve device <zfs-mountpoint>
cryptsetup: WARNING: Couldn't determine root device

under the following condition:

update-initramfs -c -k all

when:

trying to resolve for encrypted zfs devices

so here is a patch to solve it, based off

Package: cryptsetup-initramfs
Version: 2:2.1.0-1ubuntu1

diff -Naur a/usr/share/initramfs-tools/hooks/cryptroot b/usr/share/initramfs-tools/hooks/cryptroot
--- a/usr/share/initramfs-tools/hooks/cryptroot 2019-05-22 18:34:12.116097472 +0100
+++ b/usr/share/initramfs-tools/hooks/cryptroot 2019-05-22 20:13:02.159138688 +0100
@@ -72,19 +72,28 @@
             # take the last mountpoint if used several times (shadowed)
             unset -v devnos
             spec="$(printf '%b' "$spec")"
- resolve_device "$spec" || continue # resolve_device() already warns on error
             fstype="$(printf '%b' "$fstype")"
- if [ "$fstype" = "btrfs" ]; then
- # btrfs can span over multiple devices
- if uuid="$(device_uuid "$DEV")"; then
- for dev in "/sys/fs/$fstype/$uuid/devices"/*/dev; do
- devnos="${devnos:+$devnos }$(cat "$dev")"
- done
- else
- cryptsetup_message "ERROR: $spec: Couldn't determine UUID"
+ if [ "$fstype" = "zfs" ]; then
+ # zfs can span over multiple devices
+ for dev in $(zpool status -L -P | grep -o "/dev/[^ ]*"); do
+ MAJ="$(printf "%d\n" 0x$(stat -L -c"%t" -- "$dev"))"
+ MIN="$(printf "%d\n" 0x$(stat -L -c"%T" -- "$dev"))"
+ devnos="${devnos:+$devnos }$MAJ:$MIN"
+ done
+ else
+ resolve_device "$spec" || continue # resolve_device() already warns on error
+ if [ "$fstype" = "btrfs" ]; then
+ # btrfs can span over multiple devices
+ if uuid="$(device_uuid "$DEV")"; then
+ for dev in "/sys/fs/$fstype/$uuid/devices"/*/dev; do
+ devnos="${devnos:+$devnos }$(cat "$dev")"
+ done
+ else
+ cryptsetup_message "ERROR: $spec: Couldn't determine UUID"
+ fi
+ elif [ -n "$fstype" ]; then
+ devnos="$MAJ:$MIN"
                 fi
- elif [ -n "$fstype" ]; then
- devnos="$MAJ:$MIN"
             fi
         fi
     done </proc/mounts

Which works, I have tested it. However by solving this error message, the script can now continue further. And it then prints out some new messages that should not be there either. Unfortunately I could not track down the source of those subsequent warnings!

They say:

# update-initramfs -c -k all
update-initramfs: Generating /boot/initrd.img-5.0.0-15-generic
cryptsetup: WARNING: crypt_rpool1: ignoring unknown option 'nofail'
cryptsetup: WARNING: crypt_rpool1: ignoring unknown option
    'x-systemd.device-timeout'

So clearly there is something which does not recognize the fstab mounting options of:

'nofail'
and
'x-systemd.device-timeout'

However those options are indeed valid, and were found to have a working effect. They were tested also. So the warning is something else, somewhere else. And I cannot grep it. Cannot google it. Nothing happening in strace. It is pretty mysterious, as to where it is come from. Mysterious messages!

Anyhow please take the first patch if you can. Or use those lines to make your own version to improve as you please.

Tags: patch

Related branches

Revision history for this message
dreamcat4 (dreamcat4) wrote :

Oh sorry. Didn't upload the patch correctly (as an attachment). Here it is then...

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Use however you please" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in cryptsetup (Ubuntu):
status: New → Confirmed
cserem (cserem)
Changed in cryptsetup (Debian):
importance: Undecided → Unknown
status: New → Unknown
Revision history for this message
Scott Emmons (lscotte) wrote :

This was a fairly painful regression, thanks for the patch dreamcat4 - that solved it for me. The other warnings are unrelated to the patch, certainly (and did not occur for me, nor I do have those options in my fstab).

Changed in cryptsetup (Debian):
status: Unknown → New
Revision history for this message
Corny (digineo) wrote :

Thanks dreamcat4, your Patch solves the problem for me.

Revision history for this message
Brett Milford (brettmilford) wrote :

Patch works for me. Thanks dreamcat4.

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Thanks for the patch. In Ubuntu we proposed a patch based on your idea and also followed the recommendations of Debian's maintainer (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=902449) which resulted in the slightly different implementation.

The package has just been uploaded to groovy.

Changed in cryptsetup (Ubuntu):
status: Confirmed → Triaged
importance: Undecided → Medium
Revision history for this message
dreamcat4 (dreamcat4) wrote :

Oh hi there Jean... reading that debian bug report there was this comment from 2 years ago saying:

> > So, any other ideas how to integrate the ZFS support?
> Not beside parsing `zpool`'s output, which I'm afraid I still object to.

Those guys finally realized they cannot put CDDL in the GPL for /sys/fs...

Just wanted to point out in regards to that. ZOL project has been trying to make their cmdline output machine readable. However its only made its way into some newer version(bs) of zfs. Here is the PR for that feature in case it's any help to anybody.

https://github.com/openzfs/zfs/pull/7281

I understand that is not relevant for your specific patch, which you are simply just skipping zfs. And avoiding to try to parse / see. Perhaps instead for others who might come to improve initramfs in future.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cryptsetup - 2:2.3.3-1ubuntu3

---------------
cryptsetup (2:2.3.3-1ubuntu3) groovy; urgency=medium

  * debian/rules:
    - fix FTBFS on riscv64 adding --with-tmpfilesdir to ensure all archs, even
      without systemd knows how to ship cryptsetup.conf

 -- Didier Roche <email address hidden> Thu, 18 Jun 2020 11:44:50 +0200

Changed in cryptsetup (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
Cornelius (7-cornelius) wrote :

Will this patch be backported to focal? Seems like my installation is broken after upgrading from bionic to focal due to this issue. I have encrypted root partition with zfs root.

Revision history for this message
Peter Passchier (peter-passchier) wrote :

This needs to be in Focal! It's a LTS release.

Revision history for this message
Jasper Knockaert (jasper-f) wrote :

This still needs to be backported to focal...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.