1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
#!@DEFAULT_INIT_SHELL@
# SPDX-License-Identifier: BSD-2-Clause
# 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: zfs-import
# Required-Stop: $local_fs zfs-import
# 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 @IS_SYSV_RC@
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
|