diff --git a/etc/init.d/README.md b/etc/init.d/README.md index f417b24c5923..2de05042ce63 100644 --- a/etc/init.d/README.md +++ b/etc/init.d/README.md @@ -1,75 +1,75 @@ DESCRIPTION These script were written with the primary intention of being portable and usable on as many systems as possible. This is, in practice, usually not possible. But the intention is there. And it is a good one. They have been tested successfully on: * Debian GNU/Linux Wheezy * Debian GNU/Linux Jessie * Ubuntu Trusty * CentOS 6.0 * CentOS 6.6 * Gentoo SUPPORT If you find that they don't work for your platform, please report this at the OpenZFS issue tracker at https://github.com/openzfs/zfs/issues. Please include: * Distribution name * Distribution version * Where to find an install CD image * Architecture If you have code to share that fixes the problem, that is much better. But please remember to try your best keep portability in mind. If you suspect that what you're writing/modifying won't work on anything else than your distribution, please make sure to put that code in appropriate if/else/fi code. It currently MUST be bash (or fully compatible) for this to work. If you're making your own distribution and you want the scripts to work on that, the biggest problem you'll (probably) have is the part at the beginning of the "zfs-functions" file which sets up the logging output. INSTALLING INIT SCRIPT LINKS To setup the init script links in /etc/rc?.d manually on a Debian GNU/Linux (or derived) system, run the following commands (the order is important!): update-rc.d zfs-import start 07 S . stop 07 0 1 6 . update-rc.d zfs-load-key start 02 2 3 4 5 . stop 06 0 1 6 . - update-rc.d zfs-mount start 02 2 3 4 5 . stop 06 0 1 6 . + update-rc.d zfs-mount start 02 S . stop 06 0 1 6 . update-rc.d zfs-zed start 07 2 3 4 5 . stop 08 0 1 6 . update-rc.d zfs-share start 27 2 3 4 5 . stop 05 0 1 6 . To do the same on RedHat, Fedora and/or CentOS: chkconfig zfs-import chkconfig zfs-load-key chkconfig zfs-mount chkconfig zfs-zed chkconfig zfs-share On Gentoo: rc-update add zfs-import boot rc-update add zfs-load-key boot rc-update add zfs-mount boot rc-update add zfs-zed default rc-update add zfs-share default The idea here is to make sure all of the ZFS filesystems, including possibly separate datasets like /var, are mounted before anything else is started. Then, ZED, which depends on /var, can be started. It will consume and act on events that occurred before it started. ZED may also play a role in sharing filesystems in the future, so it is important to start before the 'share' service. Finally, we share filesystems configured with the share\* property. diff --git a/etc/init.d/zfs-mount.in b/etc/init.d/zfs-mount.in index df28c6c951c5..a0825f19fcdd 100755 --- a/etc/init.d/zfs-mount.in +++ b/etc/init.d/zfs-mount.in @@ -1,141 +1,142 @@ #!@DEFAULT_INIT_SHELL@ # shellcheck disable=SC2154 # # zfs-mount This script will mount/umount the zfs filesystems. # # chkconfig: 2345 06 99 # description: This script will mount/umount the zfs filesystems during # system boot/shutdown. Configuration of which filesystems # should be mounted is handled by the zfs 'mountpoint' and # 'canmount' properties. See the zfs(8) man page for details. # It is also responsible for all userspace zfs services. # probe: true # ### BEGIN INIT INFO # Provides: zfs-mount -# Required-Start: $local_fs zfs-import +# Required-Start: zfs-import # Required-Stop: $local_fs zfs-import -# Default-Start: 2 3 4 5 +# Default-Start: S # Default-Stop: 0 1 6 +# X-Start-Before: mountall # X-Stop-After: zfs-zed # Short-Description: Mount ZFS filesystems and volumes # Description: Run the `zfs mount -a` or `zfs umount -a` commands. ### END INIT INFO # # Released under the 2-clause BSD license. # # This script is based on debian/zfsutils.zfs.init from the # Debian GNU/kFreeBSD zfsutils 8.1-3 package, written by Aurelien Jarno. # Source the common init script . @sysconfdir@/zfs/zfs-functions # ---------------------------------------------------- chkroot() { while read -r _ mp _; do if [ "$mp" = "/" ]; then return 0 fi done < /proc/self/mounts return 1 } do_depend() { # Try to allow people to mix and match fstab with ZFS in a way that makes sense. if [ "$(mountinfo -s /)" = 'zfs' ] then before localmount else after localmount fi # bootmisc will log to /var which may be a different zfs than root. before bootmisc logger after zfs-import sysfs use mtab keyword -lxc -openvz -prefix -vserver } # Mount all datasets/filesystems do_mount() { local verbose overlay check_boolean "$VERBOSE_MOUNT" && verbose=v check_boolean "$DO_OVERLAY_MOUNTS" && overlay=O zfs_action "Mounting ZFS filesystem(s)" \ "$ZFS" mount "-a$verbose$overlay" "$MOUNT_EXTRA_OPTIONS" return 0 } # Unmount all filesystems do_unmount() { # This shouldn't really be necessary, as long as one can get # zfs-import to run sufficiently late in the shutdown/reboot process # - after unmounting local filesystems. This is just here in case/if # this isn't possible. zfs_action "Unmounting ZFS filesystems" "$ZFS" unmount -a return 0 } do_start() { check_boolean "$ZFS_MOUNT" || exit 0 check_module_loaded "zfs" || exit 0 # Ensure / exists in /proc/self/mounts. # This should be handled by rc.sysinit but lets be paranoid. if ! chkroot then mount -f / fi do_mount } do_stop() { check_boolean "$ZFS_UNMOUNT" || exit 0 check_module_loaded "zfs" || exit 0 do_unmount } # ---------------------------------------------------- if [ ! -e /sbin/openrc-run ] then case "$1" in start) do_start ;; stop) do_stop ;; force-reload|condrestart|reload|restart|status) # no-op ;; *) [ -n "$1" ] && echo "Error: Unknown command $1." echo "Usage: $0 {start|stop}" exit 3 ;; esac exit $? else # Create wrapper functions since Gentoo don't use the case part. depend() { do_depend; } start() { do_start; } stop() { do_stop; } fi