From f1de1600d132666d03b3b73a2ab62695a0f60ead Mon Sep 17 00:00:00 2001 From: Jonathon <559369+jonathonf@users.noreply.github.com> Date: Sun, 2 Aug 2020 00:13:15 +0000 Subject: [PATCH] Verify zfs module loaded before starting services This is a minor change to the systemd service templates that verifies the zfs kernel module is loaded by the kernel prior to attempting to import any zpool. The services check for the presence of /sys/module/zfs which indicates the zfs is module is loaded. This uses the systemd built-in check ConditionPathIsDirectory. Reviewed-by: Richard Laager Reviewed-by: Brian Behlendorf Reviewed-by: Matthew Thode Signed-off-by: Jonathon Fernyhough Closes #10663 --- etc/systemd/system/zfs-import-cache.service.in | 2 +- etc/systemd/system/zfs-import-scan.service.in | 2 +- etc/systemd/system/zfs-mount.service.in | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/etc/systemd/system/zfs-import-cache.service.in b/etc/systemd/system/zfs-import-cache.service.in index 3697f09c7f..47c5b07f8f 100644 --- a/etc/systemd/system/zfs-import-cache.service.in +++ b/etc/systemd/system/zfs-import-cache.service.in @@ -9,11 +9,11 @@ After=multipathd.target After=systemd-remount-fs.service Before=zfs-import.target ConditionPathExists=@sysconfdir@/zfs/zpool.cache +ConditionPathIsDirectory=/sys/module/zfs [Service] Type=oneshot RemainAfterExit=yes -ExecCondition=/usr/bin/grep -q "^zfs " /proc/modules ExecStart=@sbindir@/zpool import -c @sysconfdir@/zfs/zpool.cache -aN [Install] diff --git a/etc/systemd/system/zfs-import-scan.service.in b/etc/systemd/system/zfs-import-scan.service.in index 1a352a8acb..6520f32463 100644 --- a/etc/systemd/system/zfs-import-scan.service.in +++ b/etc/systemd/system/zfs-import-scan.service.in @@ -8,11 +8,11 @@ After=cryptsetup.target After=multipathd.target Before=zfs-import.target ConditionPathExists=!@sysconfdir@/zfs/zpool.cache +ConditionPathIsDirectory=/sys/module/zfs [Service] Type=oneshot RemainAfterExit=yes -ExecCondition=/usr/bin/grep -q "^zfs " /proc/modules ExecStart=@sbindir@/zpool import -aN -o cachefile=none [Install] diff --git a/etc/systemd/system/zfs-mount.service.in b/etc/systemd/system/zfs-mount.service.in index e0d4bb37f6..480f39a497 100644 --- a/etc/systemd/system/zfs-mount.service.in +++ b/etc/systemd/system/zfs-mount.service.in @@ -7,11 +7,11 @@ After=zfs-import.target After=systemd-remount-fs.service Before=local-fs.target Before=systemd-random-seed.service +ConditionPathIsDirectory=/sys/module/zfs [Service] Type=oneshot RemainAfterExit=yes -ExecCondition=/usr/bin/grep -q "^zfs " /proc/modules ExecStart=@sbindir@/zfs mount -a [Install]