Comment 10 for bug 1661629

Revision history for this message
John Gallagher (john.gallagher) wrote :

> It might be easier to resolve this by considering this as "mkinitramfs
fails on ZFS root without /etc/fstab lines for the ZFS filesystems when
MODULES=dep is used".

Yes, that sounds like an accurate summary. I'm not sure I follow how /etc/fstab is related, though. Looking briefly through mkinitramfs, I don't see where that is being used.

> Could you perhaps see if you can remove kdump-tools from the equation
like this?

Good idea. Here is a more minimal way to reproduce the issue: with ZFS on root
 - set 'MODULES=dep' in '/etc/initramfs-tools/initramfs.conf'
 - run 'sudo update-initramfs -u'

Below is an updated patch, which finds and adds the module for each device in the zfs pool containing the root filesystem. I've tested the patch on Bionic and Cosmic with both zfs and ext4 root filesystems. Note that I wasn't entirely sure if we need to handle the case where 'dev_node' is /dev/root. I'm not familiar with that setup, so I'm not sure whether that could even apply when using zfs on root.

--- hook-functions 2018-07-10 22:19:18.489142772 +0000
+++ /usr/share/initramfs-tools/hook-functions 2018-07-10 22:06:43.969661842 +0000
@@ -357,6 +357,21 @@
                return
        fi

+ if [ "${FSTYPE}" = "zfs" ]; then
+ manual_add_modules "${FSTYPE}"
+
+ # ZFS uses the name of a filesystem instead of a device. Find
+ # the devices that make up the pool containing the specified
+ # filesystem, and add the appropriate driver for each device.
+ local poolname="${dev_node%%/*}"
+ zpool list -vPL "$poolname" | while read dev ignored; do
+ # Ignore non-leaf vdevs by skipping anything that doesn't
+ # look like an absolute path
+ echo "$dev" | grep -q '^/' && block_dev_mod_add "$dev"
+ done
+ return
+ fi
+
        if [ "$dir" = / ] && [ "${dev_node}" = "/dev/root" ] ; then
                if [ -b "${dev_node}" ]; then
                        # Match it to the canonical device name by UUID