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.
18 # Default-Start: 2 3 4 5
20 # Short-Description: Mount/umount the zfs filesystems
21 # Description: ZFS is an advanced filesystem designed to simplify managing
22 # and protecting your data. This service mounts the ZFS
23 # filesystems and starts all related zfs services.
26 export PATH=/usr/local/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
28 # Source function library & LSB routines
29 . /etc/rc.d/init.d/functions
36 LOCKFILE=/var/lock/subsys/$servicename
40 modinfo zfs > /dev/null 2>&1 || return 5
41 $ZPOOL > /dev/null 2>&1
42 [ $? == 127 ] && return 5
44 [ $? == 127 ] && return 5
48 # i need a bash guru to simplify this, since this is copy and paste, but donno how
49 # to correctly dereference variable names in bash, or how to do this right
51 # first parameter is a regular expression that filters fstab
55 while read -r fs mntpnt fstype opts blah ; do
56 fs=`printf '%b\n' "$fs"`
59 done < <(egrep "$1" /etc/fstab)
64 # Disable lockfile check
65 # if [ -f "$LOCKFILE" ] ; then return 0 ; fi
67 # check if ZFS is installed. If not, comply to FC standards and bail
69 action $"Checking if ZFS is installed: not installed" /bin/false
73 # Requires selinux policy which has not been written.
74 if [ -r "/selinux/enforce" ] &&
75 [ "$(cat /selinux/enforce)" = "1" ]; then
76 action $"SELinux ZFS policy required: " /bin/false || return 6
79 # Delay until all required block devices are present.
82 # load kernel module infrastructure
83 if ! grep -q zfs /proc/modules ; then
84 action $"Loading kernel ZFS infrastructure: " modprobe zfs || return 5
88 action $"Mounting automounted ZFS filesystems: " $ZFS mount -a || return 152
90 # Read fstab, try to mount zvols ignoring error
91 read_fstab "^/dev/(zd|zvol)"
92 template=$"Mounting volume %s registered in fstab: "
93 for volume in "${FSTAB[@]}" ; do
94 string=`printf "$template" "$volume"`
95 action "$string" mount "$volume" 2>/dev/null || /bin/true
103 # Disable lockfile check
104 # if [ ! -f "$LOCKFILE" ] ; then return 0 ; fi
106 # check if ZFS is installed. If not, comply to FC standards and bail
108 action $"Checking if ZFS is installed: not installed" /bin/false
112 # the poweroff of the system takes care of this
113 # but it never unmounts the root filesystem itself
116 action $"Syncing ZFS filesystems: " sync
117 # about the only thing we can do, and then we
118 # hope that the umount process will succeed
119 # unfortunately the umount process does not dismount
120 # the root file system, there ought to be some way
121 # we can tell zfs to just flush anything in memory
122 # when a request to remount,ro comes in
124 #echo -n $"Unmounting ZFS filesystems: "
127 #if [ $RETVAL -ne 0 ]; then
137 # See how we are called
148 lsmod | grep -q zfs || RETVAL=3
149 $ZPOOL status && echo && $ZFS list || {
150 [ -f "$LOCKFILE" ] && RETVAL=2 || RETVAL=4
158 if [ -f "$LOCKFILE" ] ; then
164 echo $"Usage: $0 {start|stop|status|restart|condrestart}"