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 <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matthew Thode <prometheanfire@gentoo.org>
Signed-off-by: Jonathon Fernyhough <jonathon.fernyhough@york.ac.uk>
Closes #10663
This commit is contained in:
Jonathon 2020-08-02 00:13:15 +00:00 committed by GitHub
parent da60484db5
commit f1de1600d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -9,11 +9,11 @@ After=multipathd.target
After=systemd-remount-fs.service After=systemd-remount-fs.service
Before=zfs-import.target Before=zfs-import.target
ConditionPathExists=@sysconfdir@/zfs/zpool.cache ConditionPathExists=@sysconfdir@/zfs/zpool.cache
ConditionPathIsDirectory=/sys/module/zfs
[Service] [Service]
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
ExecCondition=/usr/bin/grep -q "^zfs " /proc/modules
ExecStart=@sbindir@/zpool import -c @sysconfdir@/zfs/zpool.cache -aN ExecStart=@sbindir@/zpool import -c @sysconfdir@/zfs/zpool.cache -aN
[Install] [Install]

View File

@ -8,11 +8,11 @@ After=cryptsetup.target
After=multipathd.target After=multipathd.target
Before=zfs-import.target Before=zfs-import.target
ConditionPathExists=!@sysconfdir@/zfs/zpool.cache ConditionPathExists=!@sysconfdir@/zfs/zpool.cache
ConditionPathIsDirectory=/sys/module/zfs
[Service] [Service]
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
ExecCondition=/usr/bin/grep -q "^zfs " /proc/modules
ExecStart=@sbindir@/zpool import -aN -o cachefile=none ExecStart=@sbindir@/zpool import -aN -o cachefile=none
[Install] [Install]

View File

@ -7,11 +7,11 @@ After=zfs-import.target
After=systemd-remount-fs.service After=systemd-remount-fs.service
Before=local-fs.target Before=local-fs.target
Before=systemd-random-seed.service Before=systemd-random-seed.service
ConditionPathIsDirectory=/sys/module/zfs
[Service] [Service]
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
ExecCondition=/usr/bin/grep -q "^zfs " /proc/modules
ExecStart=@sbindir@/zfs mount -a ExecStart=@sbindir@/zfs mount -a
[Install] [Install]