summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2016-05-25 10:48:12 -0700
committerBrian Behlendorf <[email protected]>2016-05-27 11:54:29 -0700
commit92547bc45ca9a2114662d9343ae53e5098acb627 (patch)
treea1923d3129f467241c8af61c0791f50e056c317d
parent26ef0cc7db03be6f7a5c2d06c7ecdb2449bfa9e1 (diff)
Systemd configuration fixes
* Disable zfs-import-scan.service by default. This ensures that pools will not be automatically imported unless they appear in the cache file. When this service is explicitly enabled pools will be imported with the "cachefile=none" property set. This prevents the creation of, or update to, an existing cache file. $ systemctl list-unit-files | grep zfs zfs-import-cache.service enabled zfs-import-scan.service disabled zfs-mount.service enabled zfs-share.service enabled zfs-zed.service enabled zfs.target enabled * Change services to dynamic from static by adding an [Install] section and adding 'WantedBy' tags in favor of 'Requires' tags. This allows for easier customization of the boot behavior. * Start the zfs-import-cache.service after the root pivot so the cache file is available in the standard location. * Start the zfs-mount.service after the systemd-remount-fs.service to ensure the root fs is writeable and the ZFS filesystems can create their mount points. * Change the default behavior to only load the ZFS kernel modules in zfs-import-*.service or when blkid(8) detects a pool. Users who wish to unconditionally load the kernel modules must uncomment the list of modules in /lib/modules-load.d/zfs.conf. Reviewed-by: Richard Laager <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #4325 Closes #4496 Closes #4658 Closes #4699
-rw-r--r--etc/modules-load.d/zfs.conf.in4
-rw-r--r--etc/systemd/system/50-zfs.preset.in7
-rw-r--r--etc/systemd/system/zfs-import-cache.service.in5
-rw-r--r--etc/systemd/system/zfs-import-scan.service.in6
-rw-r--r--etc/systemd/system/zfs-mount.service.in8
-rw-r--r--etc/systemd/system/zfs-share.service.in6
-rw-r--r--etc/systemd/system/zfs-zed.service.in1
-rw-r--r--etc/systemd/system/zfs.target.in3
8 files changed, 29 insertions, 11 deletions
diff --git a/etc/modules-load.d/zfs.conf.in b/etc/modules-load.d/zfs.conf.in
index 73304bc2c..8b41baa30 100644
--- a/etc/modules-load.d/zfs.conf.in
+++ b/etc/modules-load.d/zfs.conf.in
@@ -1 +1,3 @@
-zfs
+# Always load kernel modules at boot. The default behavior is to load the
+# kernel modules in the zfs-import-*.service or when blkid(8) detects a pool.
+#zfs
diff --git a/etc/systemd/system/50-zfs.preset.in b/etc/systemd/system/50-zfs.preset.in
index 4efdd7200..4d82778e3 100644
--- a/etc/systemd/system/50-zfs.preset.in
+++ b/etc/systemd/system/50-zfs.preset.in
@@ -1,2 +1,7 @@
# ZFS is enabled by default
-enable zfs.*
+enable zfs-import-cache.service
+disable zfs-import-scan.service
+enable zfs-mount.service
+enable zfs-share.service
+enable zfs-zed.service
+enable zfs.target
diff --git a/etc/systemd/system/zfs-import-cache.service.in b/etc/systemd/system/zfs-import-cache.service.in
index a567b3095..02184a602 100644
--- a/etc/systemd/system/zfs-import-cache.service.in
+++ b/etc/systemd/system/zfs-import-cache.service.in
@@ -4,6 +4,7 @@ DefaultDependencies=no
Requires=systemd-udev-settle.service
After=systemd-udev-settle.service
After=cryptsetup.target
+After=systemd-remount-fs.service
Before=dracut-mount.service
ConditionPathExists=@sysconfdir@/zfs/zpool.cache
@@ -12,3 +13,7 @@ Type=oneshot
RemainAfterExit=yes
ExecStartPre=/sbin/modprobe zfs
ExecStart=@sbindir@/zpool import -c @sysconfdir@/zfs/zpool.cache -aN
+
+[Install]
+WantedBy=zfs-mount.service
+WantedBy=zfs.target
diff --git a/etc/systemd/system/zfs-import-scan.service.in b/etc/systemd/system/zfs-import-scan.service.in
index cb3c2a7bd..625f3a955 100644
--- a/etc/systemd/system/zfs-import-scan.service.in
+++ b/etc/systemd/system/zfs-import-scan.service.in
@@ -11,4 +11,8 @@ ConditionPathExists=!@sysconfdir@/zfs/zpool.cache
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/sbin/modprobe zfs
-ExecStart=@sbindir@/zpool import -d /dev/disk/by-id -aN
+ExecStart=@sbindir@/zpool import -aN -o cachefile=none
+
+[Install]
+WantedBy=zfs-mount.service
+WantedBy=zfs.target
diff --git a/etc/systemd/system/zfs-mount.service.in b/etc/systemd/system/zfs-mount.service.in
index f1056af31..0664fd9e7 100644
--- a/etc/systemd/system/zfs-mount.service.in
+++ b/etc/systemd/system/zfs-mount.service.in
@@ -1,15 +1,17 @@
[Unit]
Description=Mount ZFS filesystems
DefaultDependencies=no
-Wants=zfs-import-cache.service
-Wants=zfs-import-scan.service
-Requires=systemd-udev-settle.service
After=systemd-udev-settle.service
After=zfs-import-cache.service
After=zfs-import-scan.service
+After=systemd-remount-fs.service
Before=local-fs.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=@sbindir@/zfs mount -a
+
+[Install]
+WantedBy=zfs-share.service
+WantedBy=zfs.target
diff --git a/etc/systemd/system/zfs-share.service.in b/etc/systemd/system/zfs-share.service.in
index 1230320e3..688731ea3 100644
--- a/etc/systemd/system/zfs-share.service.in
+++ b/etc/systemd/system/zfs-share.service.in
@@ -3,12 +3,14 @@ Description=ZFS file system shares
After=nfs-server.service nfs-kernel-server.service
After=smb.service
After=zfs-mount.service
-Requires=zfs-mount.service
PartOf=nfs-server.service nfs-kernel-server.service
PartOf=smb.service
[Service]
Type=oneshot
RemainAfterExit=yes
-ExecStartPre=-@bindir@/rm /etc/dfs/sharetab
+ExecStartPre=-@bindir@/rm -f /etc/dfs/sharetab
ExecStart=@sbindir@/zfs share -a
+
+[Install]
+WantedBy=zfs.target
diff --git a/etc/systemd/system/zfs-zed.service.in b/etc/systemd/system/zfs-zed.service.in
index 4d4c9d841..e3dec3dca 100644
--- a/etc/systemd/system/zfs-zed.service.in
+++ b/etc/systemd/system/zfs-zed.service.in
@@ -10,3 +10,4 @@ Restart=on-abort
[Install]
Alias=zed.service
+WantedBy=zfs.target
diff --git a/etc/systemd/system/zfs.target.in b/etc/systemd/system/zfs.target.in
index ce110e573..4699463b0 100644
--- a/etc/systemd/system/zfs.target.in
+++ b/etc/systemd/system/zfs.target.in
@@ -1,8 +1,5 @@
[Unit]
Description=ZFS startup target
-Requires=zfs-mount.service
-Requires=zfs-share.service
-Wants=zfs-zed.service
[Install]
WantedBy=multi-user.target