Where the problem is: I am using ArchLinux with archzfs, and zfs hook in my initramfs will occasionally try (and fail) to import pools too early, before scsi scan of all disks used by ZFS had completed. This results in boot failure, since zfs is used in my system also as a root filesystem. To resolve this problem I am looking to some command which would block zfs hook execution (it is simply an ash script, stored and executed inside initramfs image) until scsi scan had completed.

How is this relevant to udevadm: If I were using linux kernel before 3.6, I would have simply added modprobe scsi_wait_scan ; rmmod scsi_wait_scan ; to block zfs hook execution until scsi scan had completed. However I am using kernel 4.4 and this module is not available. I am thinking to use udevadm settle instead, but I am not quite sure if it is actually good for this kind of usage. This is because in ArchLinux there is already udev hook, which is executed before zfs hook and does the following:

run_hook() { msg ":: Triggering uevents..." udevadm trigger --action=add --type=subsystems udevadm trigger --action=add --type=devices udevadm settle }

So, following https://bugs.launchpad.net/ironic-python-agent/+bug/1551300 I decided to instead add two lines to zfs hook (before zfs import)

# Force udev to list all devices, will block until scsi scan is completed udevadm trigger --verbose --dry-run --type=devices --subsystem-match=scsi_disk udevadm settle

Does this make sense? Or should I try something different? The issue with testing the solution is that the problem triggers only occasionally, which means that even if I restart my computer multiple times without seeing it again, it is not a guarantee that the problem has been fixed. So, the question asked here is not to fix my initramfs for me, but to confirm (or deny) whether udevadm can be used to wait for scsi scan to complete, and if so - how.


Interestingly enough it appears that udevadm settle does not prevent zfs from loading before scanning of scsi devices had completed. I've finally fixed the problem by forcing synchronous scsi scanning, like this

bronek@gdansk ~ % cat /etc/modprobe.d/zfs.conf
# Enforce synchronous scsi scan, to prevent zfs driver loading before disks are available
options scsi_mod scan=sync

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.