[Bug 1830110] Re: patch for finding zfs, solves: cryptsetup: WARNING: Couldn't determine root device

dreamcat4 1830110 at bugs.launchpad.net
Thu Jun 18 09:45:05 UTC 2020


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.

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to cryptsetup in Ubuntu.
https://bugs.launchpad.net/bugs/1830110

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

Status in cryptsetup package in Ubuntu:
  Triaged
Status in cryptsetup package in Debian:
  New

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.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cryptsetup/+bug/1830110/+subscriptions



More information about the foundations-bugs mailing list