well… not so fast, lol
Implementing on real system it worked as expected until kernel update, after which some timings seem to have changed.
After boot:
# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
zroot 3.62T 373G 3.26T - - 16% 10% 1.00x ONLINE -
# systemctl status zfs-storage-pool-import-loadkey-mount.service
× zfs-storage-pool-import-loadkey-mount.service - Import and load-keys and mount storage pool
Loaded: loaded (/etc/systemd/system/zfs-storage-pool-import-loadkey-mount.service; enabled; preset: disabled)
Drop-In: /usr/lib/systemd/system/service.d
└─10-timeout-abort.conf
Active: failed (Result: exit-code) since Sun 2025-09-21 17:52:48 EEST; 3min 44s ago
Invocation: 27a84d8cf0cd4f2fa6acfd1ca32cd22a
Process: 2436 ExecStartPre=/usr/bin/test -e /dev/disk/by-id/dm-name-hgst-10t-disk0 (code=exited, status=1/FAILURE)
Sep 21 17:52:48 k8p systemd[1]: zfs-storage-pool-import-loadkey-mount.service: Scheduled restart job, restart counter is at 5.
Sep 21 17:52:48 k8p systemd[1]: zfs-storage-pool-import-loadkey-mount.service: Start request repeated too quickly.
Sep 21 17:52:48 k8p systemd[1]: zfs-storage-pool-import-loadkey-mount.service: Failed with result 'exit-code'.
# systemctl start zfs-storage-pool-import-loadkey-mount.service
# systemctl status zfs-storage-pool-import-loadkey-mount.service
● zfs-storage-pool-import-loadkey-mount.service - Import and load-keys and mount storage pool
Loaded: loaded (/etc/systemd/system/zfs-storage-pool-import-loadkey-mount.service; enabled; preset: disabled)
Drop-In: /usr/lib/systemd/system/service.d
└─10-timeout-abort.conf
Active: active (exited) since Sun 2025-09-21 17:57:10 EEST; 1s ago
Invocation: bd8e30438202433fbab2b740ee4f468c
Process: 4604 ExecStartPre=/usr/bin/test -e /dev/disk/by-id/dm-name-hgst-10t-disk0 (code=exited, status=0/SUCCESS)
Process: 4606 ExecStartPre=/usr/bin/test -e /dev/disk/by-id/dm-name-hgst-10t-disk1 (code=exited, status=0/SUCCESS)
Process: 4607 ExecStart=/usr/sbin/zpool import -o cachefile=/etc/zfs/storage.cache storage (code=exited, status=0/SUCCESS)
Process: 4846 ExecStart=/usr/sbin/zfs load-key storage (code=exited, status=0/SUCCESS)
Process: 4885 ExecStart=/usr/sbin/zfs mount -a (code=exited, status=0/SUCCESS)
Main PID: 4885 (code=exited, status=0/SUCCESS)
Mem peak: 12.3M
CPU: 148ms
Sep 21 17:57:07 k8p systemd[1]: Starting zfs-storage-pool-import-loadkey-mount.service - Import and load-keys and mount storage pool...
Sep 21 17:57:10 k8p systemd[1]: Finished zfs-storage-pool-import-loadkey-mount.service - Import and load-keys and mount storage pool.
# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
storage 9.09T 4.22T 4.87T - - 12% 46% 1.00x ONLINE -
zroot 3.62T 373G 3.26T - - 16% 10% 1.00x ONLINE -
this is with two disks, ie:
[Unit]
Description=Import and load-keys and mount storage pool
Requires=multipathd.service
After=network-online.target
After=multipathd.service
After=iscsid.service
Before=nfs-server.service
[Service]
Type=oneshot
RemainAfterExit=yes
RestartSec=1
Restart=on-failure
ExecStartPre=/usr/bin/test -e /dev/disk/by-id/dm-name-hgst-10t-disk0
ExecStartPre=/usr/bin/test -e /dev/disk/by-id/dm-name-hgst-10t-disk1
ExecStart=/usr/sbin/zpool import -o cachefile=/etc/zfs/storage.cache storage
ExecStart=-/usr/sbin/zfs load-key storage
ExecStart=-/usr/sbin/zfs mount -a
ExecStop=/usr/sbin/zpool export storage
ExecStop=/usr/bin/sleep 15
[Install]
WantedBy=multi-user.target
So maybe it needs a sleep command yet somewhere?
edit: looking at logs, iscsid and multipathd are still working after the service runs..
Sep 21 17:52:47 k8p iscsid[2112]: iscsid: connect to 10.0.0.240:3260 failed (No route to host)
Sep 21 17:52:47 k8p sddm-helper-start-wayland[2172]: "QSGContext::initialize: depth buffer support missing, expect rendering errors\nQSGContext::initialize: stencil buffer support missing, expect rendering errors\n"
Sep 21 17:52:47 k8p kernel: amdgpu 0000:c6:00.0: [drm] *ERROR* Got unknown request 0x30 (SINK_EVENT_NOTIFY)
Sep 21 17:52:47 k8p systemd[1]: zfs-storage-pool-import-loadkey-mount.service: Scheduled restart job, restart counter is at 4.
Sep 21 17:52:47 k8p systemd[1]: Starting zfs-storage-pool-import-loadkey-mount.service - Import and load-keys and mount storage pool...
Sep 21 17:52:47 k8p systemd[1]: zfs-storage-pool-import-loadkey-mount.service: Control process exited, code=exited, status=1/FAILURE
Sep 21 17:52:47 k8p systemd[1]: zfs-storage-pool-import-loadkey-mount.service: Failed with result 'exit-code'.
Sep 21 17:52:47 k8p systemd[1]: Failed to start zfs-storage-pool-import-loadkey-mount.service - Import and load-keys and mount storage pool.
Sep 21 17:52:47 k8p audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=zfs-storage-pool-import-loadkey-mount comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
Sep 21 17:52:48 k8p kernel: scsi host0: iSCSI Initiator over TCP/IP
Sep 21 17:52:48 k8p iscsid[2112]: iscsid: Connection1:0 to [target: iqn.2005-01.env.pve.pve2.iscsi:k8p, portal: 192.168.2.240,3260] through [iface: default] is operational now
Sep 21 17:52:48 k8p kernel: scsi 0:0:0:0: Direct-Access LIO-ORG hgst-10tb-disk0 4.0 PQ: 0 ANSI: 6
Sep 21 17:52:48 k8p kernel: scsi 0:0:0:0: alua: supports implicit and explicit TPGS
Sep 21 17:52:48 k8p kernel: scsi 0:0:0:0: alua: device naa.60014059e827fb602ec4d96929f7458c port group 0 rel port 1
Sep 21 17:52:48 k8p kernel: sd 0:0:0:0: Attached scsi generic sg0 type 0
Sep 21 17:52:48 k8p kernel: sd 0:0:0:0: [sda] 19532873728 512-byte logical blocks: (10.0 TB/9.10 TiB)
Sep 21 17:52:48 k8p kernel: sd 0:0:0:0: [sda] 4096-byte physical blocks
Sep 21 17:52:48 k8p kernel: sd 0:0:0:0: [sda] Write Protect is off
Sep 21 17:52:48 k8p kernel: sd 0:0:0:0: [sda] Mode Sense: 43 00 10 08
Sep 21 17:52:48 k8p kernel: sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA
Sep 21 17:52:48 k8p kernel: scsi 0:0:0:1: Direct-Access LIO-ORG hgst-10tb-disk1 4.0 PQ: 0 ANSI: 6
Sep 21 17:52:48 k8p kernel: sd 0:0:0:0: [sda] Preferred minimum I/O size 4096 bytes
Sep 21 17:52:48 k8p kernel: sd 0:0:0:0: [sda] Optimal transfer size 33550336 bytes
Sep 21 17:52:48 k8p kernel: scsi 0:0:0:1: alua: supports implicit and explicit TPGS
Sep 21 17:52:48 k8p kernel: scsi 0:0:0:1: alua: device naa.6001405b575fb6aa7d44bc79fa6d870c port group 0 rel port 1
Sep 21 17:52:48 k8p kernel: sd 0:0:0:1: Attached scsi generic sg1 type 0
Sep 21 17:52:48 k8p kernel: sd 0:0:0:1: [sdb] 19532873728 512-byte logical blocks: (10.0 TB/9.10 TiB)
Sep 21 17:52:48 k8p kernel: sd 0:0:0:1: [sdb] 4096-byte physical blocks
Sep 21 17:52:48 k8p kernel: sd 0:0:0:1: [sdb] Write Protect is off
Sep 21 17:52:48 k8p kernel: sd 0:0:0:1: [sdb] Mode Sense: 43 00 10 08
Sep 21 17:52:48 k8p kernel: sd 0:0:0:1: [sdb] Write cache: enabled, read cache: enabled, supports DPO and FUA
Sep 21 17:52:48 k8p iscsid[2442]: iscsid: connection1:0 IPC qtask write failed: Broken pipe
Sep 21 17:52:48 k8p kernel: sd 0:0:0:1: [sdb] Preferred minimum I/O size 4096 bytes
Sep 21 17:52:48 k8p kernel: sd 0:0:0:1: [sdb] Optimal transfer size 33550336 bytes
Sep 21 17:52:48 k8p kernel: sda: sda1 sda9
Sep 21 17:52:48 k8p kernel: sd 0:0:0:0: [sda] Attached SCSI disk
Sep 21 17:52:48 k8p kernel: sdb: sdb1 sdb9
Sep 21 17:52:48 k8p kernel: sd 0:0:0:1: [sdb] Attached SCSI disk
Sep 21 17:52:48 k8p multipathd[1262]: libmp_mapinfo: map hgst-10t-disk1 doesn't exist
Sep 21 17:52:48 k8p multipathd[1262]: libmp_mapinfo: map hgst-10t-disk1 doesn't exist
Sep 21 17:52:48 k8p multipathd[1262]: hgst-10t-disk1: addmap [0 19532873728 multipath 1 queue_if_no_path 1 alua 1 1 service-time 0 1 1 8:16 1]
Sep 21 17:52:48 k8p systemd-homed[1768]: block device /sys/devices/platform/host0/session1/target0:0:0/0:0:0:1/block/sdb/sdb1 has been removed.
Sep 21 17:52:48 k8p systemd-homed[1768]: block device /sys/devices/platform/host0/session1/target0:0:0/0:0:0:1/block/sdb/sdb9 has been removed.
Sep 21 17:52:48 k8p kernel: device-mapper: multipath service-time: version 0.3.0 loaded
Sep 21 17:52:48 k8p systemd-homed[1768]: block device /sys/devices/platform/host0/session1/target0:0:0/0:0:0:0/block/sda/sda1 has been removed.
Sep 21 17:52:48 k8p systemd-homed[1768]: block device /sys/devices/platform/host0/session1/target0:0:0/0:0:0:0/block/sda/sda9 has been removed.
Sep 21 17:52:48 k8p multipathd[1262]: sdb [8:16]: path added to devmap hgst-10t-disk1
Sep 21 17:52:48 k8p multipathd[1262]: libmp_mapinfo: map hgst-10t-disk0 doesn't exist
Sep 21 17:52:48 k8p multipathd[1262]: libmp_mapinfo: map hgst-10t-disk0 doesn't exist
Sep 21 17:52:48 k8p multipathd[1262]: hgst-10t-disk0: addmap [0 19532873728 multipath 1 queue_if_no_path 1 alua 1 1 service-time 0 1 1 8:0 1]
Sep 21 17:52:48 k8p kernel: sd 0:0:0:1: alua: transition timeout set to 60 seconds
Sep 21 17:52:48 k8p kernel: sd 0:0:0:1: alua: port group 00 state A non-preferred supports TOlUSNA
Sep 21 17:52:48 k8p multipathd[1262]: sda [8:0]: path added to devmap hgst-10t-disk0
Sep 21 17:52:48 k8p kernel: sd 0:0:0:0: alua: transition timeout set to 60 seconds
Sep 21 17:52:48 k8p kernel: sd 0:0:0:0: alua: port group 00 state A non-preferred supports TOlUSNA
Sep 21 17:52:48 k8p systemd[1]: zfs-storage-pool-import-loadkey-mount.service: Scheduled restart job, restart counter is at 5.
Sep 21 17:52:48 k8p audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=zfs-storage-pool-import-loadkey-mount comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
Sep 21 17:52:48 k8p systemd[1]: zfs-storage-pool-import-loadkey-mount.service: Start request repeated too quickly.
Sep 21 17:52:48 k8p systemd[1]: zfs-storage-pool-import-loadkey-mount.service: Failed with result 'exit-code'.
Sep 21 17:52:48 k8p systemd[1]: Failed to start zfs-storage-pool-import-loadkey-mount.service - Import and load-keys and mount storage pool.
Sep 21 17:52:49 k8p multipathd[1262]: hgst-10t-disk0: sda - directio checker reports path is up
Sep 21 17:52:49 k8p multipathd[1262]: 8:0: reinstated
Sep 21 17:52:49 k8p multipathd[1262]: hgst-10t-disk0: remaining active paths: 1
Sep 21 17:52:52 k8p kernel: scsi host1: iSCSI Initiator over TCP/IP
Sep 21 17:52:52 k8p iscsid[2112]: iscsid: Connection2:0 to [target: iqn.2005-01.env.pve.pve2.iscsi:k8p, portal: 10.0.0.240,3260] through [iface: default] is operational now
Sep 21 17:52:52 k8p kernel: scsi 1:0:0:0: Direct-Access LIO-ORG hgst-10tb-disk0 4.0 PQ: 0 ANSI: 6
Sep 21 17:52:52 k8p kernel: scsi 1:0:0:0: alua: supports implicit and explicit TPGS
Sep 21 17:52:52 k8p kernel: scsi 1:0:0:0: alua: device naa.60014059e827fb602ec4d96929f7458c port group 0 rel port 1
Sep 21 17:52:52 k8p kernel: sd 1:0:0:0: Attached scsi generic sg2 type 0
Sep 21 17:52:52 k8p kernel: sd 1:0:0:0: [sdc] 19532873728 512-byte logical blocks: (10.0 TB/9.10 TiB)
Sep 21 17:52:52 k8p kernel: sd 1:0:0:0: [sdc] 4096-byte physical blocks
Sep 21 17:52:52 k8p kernel: sd 1:0:0:0: [sdc] Write Protect is off
Sep 21 17:52:52 k8p kernel: sd 1:0:0:0: [sdc] Mode Sense: 43 00 10 08
Sep 21 17:52:52 k8p kernel: sd 1:0:0:0: [sdc] Write cache: enabled, read cache: enabled, supports DPO and FUA
Sep 21 17:52:52 k8p kernel: scsi 1:0:0:1: Direct-Access LIO-ORG hgst-10tb-disk1 4.0 PQ: 0 ANSI: 6
Sep 21 17:52:52 k8p kernel: sd 1:0:0:0: [sdc] Preferred minimum I/O size 4096 bytes
Sep 21 17:52:52 k8p kernel: sd 1:0:0:0: [sdc] Optimal transfer size 33550336 bytes
Sep 21 17:52:52 k8p iscsid[2545]: iscsid: connection2:0 IPC qtask write failed: Broken pipe
Sep 21 17:52:52 k8p kernel: scsi 1:0:0:1: alua: supports implicit and explicit TPGS
Sep 21 17:52:52 k8p kernel: scsi 1:0:0:1: alua: device naa.6001405b575fb6aa7d44bc79fa6d870c port group 0 rel port 1
Sep 21 17:52:52 k8p kernel: sd 1:0:0:1: Attached scsi generic sg3 type 0
Sep 21 17:52:52 k8p kernel: sd 1:0:0:1: [sdd] 19532873728 512-byte logical blocks: (10.0 TB/9.10 TiB)
Sep 21 17:52:52 k8p kernel: sd 1:0:0:1: [sdd] 4096-byte physical blocks
Sep 21 17:52:52 k8p kernel: sd 1:0:0:1: [sdd] Write Protect is off
Sep 21 17:52:52 k8p kernel: sd 1:0:0:1: [sdd] Mode Sense: 43 00 10 08
Sep 21 17:52:52 k8p kernel: sd 1:0:0:1: [sdd] Write cache: enabled, read cache: enabled, supports DPO and FUA
Sep 21 17:52:52 k8p kernel: sd 1:0:0:1: [sdd] Preferred minimum I/O size 4096 bytes
Sep 21 17:52:52 k8p kernel: sd 1:0:0:1: [sdd] Optimal transfer size 33550336 bytes
Sep 21 17:52:52 k8p kernel: sdc: sdc1 sdc9
Sep 21 17:52:52 k8p kernel: sd 1:0:0:0: [sdc] Attached SCSI disk
Sep 21 17:52:52 k8p kernel: sdd: sdd1 sdd9
Sep 21 17:52:52 k8p kernel: sd 1:0:0:1: [sdd] Attached SCSI disk
Sep 21 17:52:52 k8p multipathd[1262]: hgst-10t-disk0: reload [0 19532873728 multipath 1 queue_if_no_path 1 alua 1 1 service-time 0 2 1 8:0 1 8:32 1]
Sep 21 17:52:52 k8p systemd-homed[1768]: block device /sys/devices/platform/host1/session2/target1:0:0/1:0:0:0/block/sdc/sdc1 has been removed.
Sep 21 17:52:52 k8p systemd-homed[1768]: block device /sys/devices/platform/host1/session2/target1:0:0/1:0:0:0/block/sdc/sdc9 has been removed.
Sep 21 17:52:52 k8p systemd-homed[1768]: block device /sys/devices/platform/host1/session2/target1:0:0/1:0:0:1/block/sdd/sdd9 has been removed.
Sep 21 17:52:52 k8p systemd-homed[1768]: block device /sys/devices/platform/host1/session2/target1:0:0/1:0:0:1/block/sdd/sdd1 has been removed.
Sep 21 17:52:52 k8p multipathd[1262]: sdc [8:32]: path added to devmap hgst-10t-disk0
Sep 21 17:52:52 k8p multipathd[1262]: hgst-10t-disk1: reload [0 19532873728 multipath 1 queue_if_no_path 1 alua 1 1 service-time 0 2 1 8:16 1 8:48 1]
Sep 21 17:52:52 k8p multipathd[1262]: sdd [8:48]: path added to devmap hgst-10t-disk1
edit2: i added ExecStart=/usr/bin/sleep 10 before the two ExecStartPre commands, and now it seems ok.. wish there was a more clean way..