3 # zfs This script will mount/umount the zfs filesystems.
5 # chkconfig: 2345 01 99
6 # description: This script will mount/umount the zfs filesystems during
7 # system boot/shutdown. Configuration of which filesystems
8 # should be mounted is handled by the zfs 'mountpoint' and
9 # 'canmount' properties. See the zfs(8) man page for details.
10 # It is also responsible for all userspace zfs services.
14 # Required-Start: $local_fs
15 # Required-Stop: $local_fs
16 # Default-Start: 2 3 4 5
19 # Short-Description: Mount/umount the zfs filesystems
20 # Description: ZFS is an advanced filesystem designed to simplify managing
21 # and protecting your data. This service mounts the ZFS
22 # filesystems and starts all related zfs services.
25 # Source function library.
26 . /lib/lsb/init-functions
28 LOCKFILE=/var/lock/zfs
30 ZPOOL="@sbindir@/zpool"
31 ZPOOL_CACHE="@sysconfdir@/zfs/zpool.cache"
33 # Source zfs configuration.
34 [ -r '/etc/default/zfs' ] && . /etc/default/zfs
36 [ -x "$ZPOOL" ] || exit 1
37 [ -x "$ZFS" ] || exit 2
39 if [ -z "$init" ]; then
41 grep -Eqi 'zfs=off|zfs=no' /proc/cmdline && exit 3
46 [ -f "$LOCKFILE" ] && return 3
48 # Requires selinux policy which has not been written.
49 if [ -r "/selinux/enforce" ] &&
50 [ "$(cat /selinux/enforce)" = "1" ]; then
52 log_failure_msg "SELinux ZFS policy required"
56 # Delay until all required block devices are present.
59 # Load the zfs module stack
62 # Ensure / exists in /etc/mtab, if not update mtab accordingly.
63 # This should be handled by rc.sysinit but lets be paranoid.
64 awk '$2 == "/" { exit 1 }' /etc/mtab
66 if [ "$RETVAL" -eq 0 ]; then
70 # Import all pools described by the cache file, and then mount
71 # all filesystem based on their properties.
72 if [ -f "$ZPOOL_CACHE" ] ; then
73 log_begin_msg "Importing ZFS pools"
74 "$ZPOOL" import -c "$ZPOOL_CACHE" -aN 2>/dev/null
77 log_begin_msg "Mounting ZFS filesystems"
81 log_begin_msg "Exporting ZFS filesystems"
91 [ ! -f "$LOCKFILE" ] && return 3
93 log_begin_msg "Unmounting ZFS filesystems"
102 [ ! -f "$LOCKFILE" ] && return 3
104 "$ZPOOL" status && echo "" && "$ZPOOL" list
125 if [ -f "$LOCKFILE" ]; then
131 echo $"Usage: $0 {start|stop|status|restart|condrestart}"