2 # shellcheck disable=SC2154
4 # zfs-mount This script will mount/umount the zfs filesystems.
6 # chkconfig: 2345 06 99
7 # description: This script will mount/umount the zfs filesystems during
8 # system boot/shutdown. Configuration of which filesystems
9 # should be mounted is handled by the zfs 'mountpoint' and
10 # 'canmount' properties. See the zfs(8) man page for details.
11 # It is also responsible for all userspace zfs services.
16 # Required-Start: zfs-import
17 # Required-Stop: $local_fs zfs-import
20 # X-Start-Before: mountall
21 # X-Stop-After: zfs-zed
22 # Short-Description: Mount ZFS filesystems and volumes
23 # Description: Run the `zfs mount -a` or `zfs umount -a` commands.
26 # Released under the 2-clause BSD license.
28 # This script is based on debian/zfsutils.zfs.init from the
29 # Debian GNU/kFreeBSD zfsutils 8.1-3 package, written by Aurelien Jarno.
31 # Source the common init script
32 . @sysconfdir@/zfs/zfs-functions
34 # ----------------------------------------------------
37 while read -r _ mp _; do
38 if [ "$mp" = "/" ]; then
41 done < /proc/self/mounts
48 # Try to allow people to mix and match fstab with ZFS in a way that makes sense.
49 if [ "$(mountinfo -s /)" = 'zfs' ]
56 # bootmisc will log to /var which may be a different zfs than root.
57 before bootmisc logger
59 after zfs-import sysfs
61 keyword -lxc -openvz -prefix -vserver
64 # Mount all datasets/filesystems
69 check_boolean "$VERBOSE_MOUNT" && verbose=v
70 check_boolean "$DO_OVERLAY_MOUNTS" && overlay=O
72 zfs_action "Mounting ZFS filesystem(s)" \
73 "$ZFS" mount "-a$verbose$overlay" "$MOUNT_EXTRA_OPTIONS"
78 # Unmount all filesystems
81 # This shouldn't really be necessary, as long as one can get
82 # zfs-import to run sufficiently late in the shutdown/reboot process
83 # - after unmounting local filesystems. This is just here in case/if
84 # this isn't possible.
85 zfs_action "Unmounting ZFS filesystems" "$ZFS" unmount -a
92 check_boolean "$ZFS_MOUNT" || exit 0
94 check_module_loaded "zfs" || exit 0
96 # Ensure / exists in /proc/self/mounts.
97 # This should be handled by rc.sysinit but lets be paranoid.
108 check_boolean "$ZFS_UNMOUNT" || exit 0
110 check_module_loaded "zfs" || exit 0
115 # ----------------------------------------------------
126 force-reload|condrestart|reload|restart|status)
130 [ -n "$1" ] && echo "Error: Unknown command $1."
131 echo "Usage: $0 {start|stop}"
138 # Create wrapper functions since Gentoo don't use the case part.
139 depend() { do_depend; }
140 start() { do_start; }