2 # Copyright 1999-2011 Gentoo Foundation
3 # Released under the 2-clause BSD license.
4 # $Header: /var/cvsroot/gentoo-x86/sys-fs/zfs/files/zfs,v 0.9 2011/04/30 10:13:43 devsk Exp $
6 if [ -z "$init" ]; then
8 grep -Eqi 'zfs=off|zfs=no' /proc/cmdline && exit 3
13 # Try to allow people to mix and match fstab with ZFS in a way that makes sense.
14 if [ "$(mountinfo -s /)" = 'zfs' ]
21 # bootmisc will log to /var which may be a different zfs than root.
22 before bootmisc logger
23 keyword -lxc -openvz -prefix -vserver
27 ZPOOL="@sbindir@/zpool"
28 ZPOOL_CACHE="@sysconfdir@/zfs/zpool.cache"
32 if [ ! -c /dev/zfs ]; then
33 einfo "Checking if ZFS modules present"
34 if ! modinfo zfs > /dev/null 2>&1 ; then
35 eerror "$ZFS_MODULE not found. Is the ZFS package installed?"
39 einfo "Checking if zfs userspace tools present"
40 if [ ! -x $ZPOOL ]; then
41 eerror "$ZPOOL binary not found."
44 if [ ! -x $ZFS ]; then
45 eerror "$ZFS binary not found."
53 checksystem || return 1
55 # Delay until all required block devices are present.
58 if [ ! -c /dev/zfs ]; then
61 if [ $rv -ne 0 ]; then
62 eerror "Failed to load the $ZFS_MODULE module, check 'dmesg|tail'."
68 # Import all pools described by the cache file, and then mount
69 # all filesystem based on their properties.
70 if [ -f $ZPOOL_CACHE ]; then
71 einfo "Importing ZFS pools"
72 # as per fedora script, import can fail if all pools are already imported
73 # The check for $rv makes no sense...but someday, it will work right.
74 $ZPOOL import -c $ZPOOL_CACHE -aN 2>/dev/null || true
76 if [ $rv -ne 0 ]; then
77 eerror "Failed to import not-yet imported pools."
83 einfo "Mounting ZFS filesystems"
86 if [ $rv -ne 0 ]; then
87 eerror "Failed to mount ZFS filesystems."
92 einfo "Exporting ZFS filesystems"
95 if [ $rv -ne 0 ]; then
96 eerror "Failed to export ZFS filesystems."
107 ebegin "Unmounting ZFS filesystems"
110 if [ $rv -ne 0 ]; then
111 einfo "Some ZFS filesystems not unmounted"
114 # Don't fail if we couldn't umount everything. /usr might be in use.
121 # show pool status and list
122 $ZPOOL status && echo && $ZPOOL list