--- /usr/share/initramfs-tools/scripts/zfs.orig 2016-04-13 12:43:25.000000000 +0200 +++ /usr/share/initramfs-tools/scripts/zfs 2017-05-18 00:21:53.582730604 +0200 @@ -1,8 +1,27 @@ # ZFS boot stub for initramfs-tools. +# JEL: pseudo-kernel parameter 'zdirs': a comma separated list of device +# directories to scan on zpool import first. This way even rpool may have/list +# non-/dev/sd* devices properly, e.g. zdirs=/dev/chassis/SYS would be scanned +# for the device with the required ID first and only if not found, it would go +# try /dev/sd* (and if bugs fixed, /dev/nvme* etc.). +check_zfs_dev_dirs() { + ZDEV_DIRS= + for x in $(cat /proc/cmdline); do + case $x in + zdirs=*) ZDEV_DIRS=",${x#zdirs=}" ;; + esac + done + if [ -n "${ZDEV_DIRS}" ]; then + ZDEV_DIRS=$( echo "${ZDEV_DIRS}" | sed -e 's/,/ -d /g' ) + else + ZDEV_DIRS= + fi +} + zfs_test_import() { - ZFS_STDERR=$(zpool import -o readonly=on -N "$ZFS_RPOOL" 2>&1) + ZFS_STDERR=$(zpool import ${ZDEV_DIRS} -o readonly=on -N "$ZFS_RPOOL" 2>&1) ZFS_ERROR=$? if [ "$ZFS_ERROR" -eq 0 ] then @@ -13,6 +32,7 @@ mountroot() { + check_zfs_dev_dirs [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-top" run_scripts /scripts/local-top [ "$quiet" != "y" ] && log_end_msg @@ -54,17 +74,17 @@ # At this point, the pool either imported cleanly, or we ran out of the # allowed time (rootdelay). Perform the read-write import. - ZFS_STDERR=$(zpool import -N "$ZFS_RPOOL" 2>&1) + ZFS_STDERR=$(zpool import ${ZDEV_DIRS} -N "$ZFS_RPOOL" 2>&1) ZFS_ERROR=$? if [ "$ZFS_ERROR" -ne 0 ] then - panic "Command: zpool import -N $ZFS_RPOOL + panic "Command: zpool import ${ZDEV_DIRS} -N $ZFS_RPOOL Message: $ZFS_STDERR Error: $ZFS_ERROR Manually import the root pool at the command prompt and then exit. -Hint: Try: zpool import -f -R / -N $ZFS_RPOOL" +Hint: Try: zpool import -f -R / ${ZDEV_DIRS} -N $ZFS_RPOOL" fi # Set elevator=noop on the root pool's vdevs' disks. ZFS already