forked from openzfs/zfs
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add systemd unit files for ZFS startup
This adds systemd unit files replacing the functionality offered by the SysV init script found in etc/init.d. It has been developed and tested on Fedora 19, Fedora 20 and openSuSE 13.1. Four unit files and one target are offered. zfs-import-cache.service: Import pools from /etc/zfs/zpool.cache. This unit will wait for udev to settle. zfs-import-scan.service: Import pools by scanning /dev/disk/by-id for zvols. This unit will only run if /etc/zfs/zpool.cache is not present. This unit will wait for udev to settle zfs-mount.service: Mount ZFS native filesystems. It contains a dependency to be loaded before local-fs.target. zfs-share.service: Share NFS/SMB filesystems. This unit contains a dependency that will cause it to be restarted whenever the smb or nfs-server unit is restarted, restoring the shares added. zfs.target: This target pulls in the other units in order to start ZFS. It's the only unit that can be enabled/disabled, all other services are static and pulled in by dependencies. It will honour zfs=off and zfs=no options on the kernel command line. Signed-off-by: Brian Behlendorf <[email protected]> Closes openzfs#2108
- Loading branch information
1 parent
c5cb66a
commit 881f45c
Showing
18 changed files
with
203 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
AC_DEFUN([ZFS_AC_CONFIG_USER_SYSTEMD], [ | ||
AC_ARG_ENABLE(systemd, | ||
AC_HELP_STRING([--enable-systemd], | ||
[install systemd unit/preset files [[default: yes]]]), | ||
[],enable_systemd=yes) | ||
AC_ARG_WITH(systemdunitdir, | ||
AC_HELP_STRING([--with-systemdunitdir=DIR], | ||
[install systemd unit files in dir [[/usr/lib/systemd/system]]]), | ||
systemdunitdir=$withval,systemdunitdir=/usr/lib/systemd/system) | ||
AC_ARG_WITH(systemdpresetdir, | ||
AC_HELP_STRING([--with-systemdpresetdir=DIR], | ||
[install systemd preset files in dir [[/usr/lib/systemd/system-preset]]]), | ||
systemdpresetdir=$withval,systemdpresetdir=/usr/lib/systemd/system-preset) | ||
AS_IF([test "x$enable_systemd" = xyes], | ||
[ | ||
ZFS_INIT_SYSTEMD=systemd | ||
ZFS_MODULE_LOAD=modules-load.d | ||
modulesloaddir=/usr/lib/modules-load.d | ||
]) | ||
AC_SUBST(ZFS_INIT_SYSTEMD) | ||
AC_SUBST(ZFS_MODULE_LOAD) | ||
AC_SUBST(systemdunitdir) | ||
AC_SUBST(systemdpresetdir) | ||
AC_SUBST(modulesloaddir) | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
AC_DEFUN([ZFS_AC_CONFIG_USER_SYSVINIT], [ | ||
AC_ARG_ENABLE(sysvinit, | ||
AC_HELP_STRING([--enable-sysvinit], | ||
[install SysV init scripts [default: yes]]), | ||
[],enable_sysvinit=yes) | ||
AS_IF([test "x$enable_sysvinit" = xyes], | ||
[ZFS_INIT_SYSV=init.d]) | ||
AC_SUBST(ZFS_INIT_SYSV) | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
SUBDIRS = init.d zfs | ||
SUBDIRS = zfs $(ZFS_INIT_SYSTEMD) $(ZFS_INIT_SYSV) $(ZFS_MODULE_LOAD) | ||
DIST_SUBDIRS = init.d zfs systemd modules-load.d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
modulesload_DATA = \ | ||
$(top_srcdir)/etc/modules-load.d/zfs.conf | ||
|
||
EXTRA_DIST = \ | ||
$(top_srcdir)/etc/modules-load.d/zfs.conf.in | ||
|
||
$(modulesload_DATA): | ||
-$(SED) \ | ||
-e '' \ | ||
'[email protected]' >'$@' | ||
|
||
distclean-local:: | ||
-$(RM) $(modulesload_DATA) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
zfs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SUBDIRS = system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.service | ||
*.target | ||
*.preset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# ZFS is enabled by default | ||
enable zfs.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
systemdpreset_DATA = \ | ||
$(top_srcdir)/etc/systemd/system/50-zfs.preset | ||
systemdunit_DATA = \ | ||
$(top_srcdir)/etc/systemd/system/zfs-import-scan.service \ | ||
$(top_srcdir)/etc/systemd/system/zfs-import-cache.service \ | ||
$(top_srcdir)/etc/systemd/system/zfs-mount.service \ | ||
$(top_srcdir)/etc/systemd/system/zfs-share.service \ | ||
$(top_srcdir)/etc/systemd/system/zfs.target | ||
|
||
EXTRA_DIST = \ | ||
$(top_srcdir)/etc/systemd/system/zfs-import-scan.service.in \ | ||
$(top_srcdir)/etc/systemd/system/zfs-import-cache.service.in \ | ||
$(top_srcdir)/etc/systemd/system/zfs-mount.service.in \ | ||
$(top_srcdir)/etc/systemd/system/zfs-share.service.in \ | ||
$(top_srcdir)/etc/systemd/system/zfs.target.in \ | ||
$(top_srcdir)/etc/systemd/system/50-zfs.preset.in | ||
|
||
$(systemdunit_DATA): | ||
-$(SED) -e 's,@bindir\@,$(bindir),g' \ | ||
-e 's,@sbindir\@,$(sbindir),g' \ | ||
-e 's,@sysconfdir\@,$(sysconfdir),g' \ | ||
'[email protected]' >'$@' | ||
|
||
$(systemdpreset_DATA): | ||
-$(SED) -e 's,@bindir\@,$(bindir),g' \ | ||
-e 's,@sbindir\@,$(sbindir),g' \ | ||
-e 's,@sysconfdir\@,$(sysconfdir),g' \ | ||
'[email protected]' >'$@' | ||
|
||
distclean-local:: | ||
-$(RM) $(systemdunit_DATA) $(systemdpreset_DATA) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[Unit] | ||
Description=Import ZFS pools by cache file | ||
DefaultDependencies=no | ||
Requires=systemd-udev-settle.service | ||
After=systemd-udev-settle.service | ||
ConditionPathExists=@sysconfdir@/zfs/zpool.cache | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=@sbindir@/zpool import -c @sysconfdir@/zfs/zpool.cache -aN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[Unit] | ||
Description=Import ZFS pools by device scanning | ||
DefaultDependencies=no | ||
Requires=systemd-udev-settle.service | ||
After=systemd-udev-settle.service | ||
ConditionPathExists=!@sysconfdir@/zfs/zpool.cache | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=@sbindir@/zpool import -d /dev/disk/by-id -aN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[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 | ||
Before=local-fs.target | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=@sbindir@/zfs mount -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[Unit] | ||
Description=ZFS file system shares | ||
After=nfs-server.service | ||
After=smb.service | ||
PartOf=nfs-server.service | ||
PartOf=smb.service | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=@sbindir@/zfs share -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[Unit] | ||
Description=ZFS startup target | ||
Requires=zfs-mount.service | ||
Requires=zfs-share.service | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters