From ae12b023082fd91e89507a2a1fc014e64c6767f0 Mon Sep 17 00:00:00 2001 From: Jonathon <559369+jonathonf@users.noreply.github.com> Date: Wed, 29 Jul 2020 23:52:18 +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. Reviewed-by: Richard Laager Reviewed-by: Brian Behlendorf Signed-off-by: Jonathon Fernyhough Closes #10627 --- etc/systemd/system/zfs-import-cache.service.in | 1 + etc/systemd/system/zfs-import-scan.service.in | 1 + etc/systemd/system/zfs-mount.service.in | 1 + 3 files changed, 3 insertions(+) diff --git a/etc/systemd/system/zfs-import-cache.service.in b/etc/systemd/system/zfs-import-cache.service.in index 82495638fd..3697f09c7f 100644 --- a/etc/systemd/system/zfs-import-cache.service.in +++ b/etc/systemd/system/zfs-import-cache.service.in @@ -13,6 +13,7 @@ ConditionPathExists=@sysconfdir@/zfs/zpool.cache [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 278f937feb..1a352a8acb 100644 --- a/etc/systemd/system/zfs-import-scan.service.in +++ b/etc/systemd/system/zfs-import-scan.service.in @@ -12,6 +12,7 @@ ConditionPathExists=!@sysconfdir@/zfs/zpool.cache [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 6507c0765d..e0d4bb37f6 100644 --- a/etc/systemd/system/zfs-mount.service.in +++ b/etc/systemd/system/zfs-mount.service.in @@ -11,6 +11,7 @@ Before=systemd-random-seed.service [Service] Type=oneshot RemainAfterExit=yes +ExecCondition=/usr/bin/grep -q "^zfs " /proc/modules ExecStart=@sbindir@/zfs mount -a [Install]