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 # bootmisc will log to /var which may be a different zfs than root.
16 keyword -lxc -openvz -prefix -vserver
20 ZPOOL="@sbindir@/zpool"
21 ZPOOL_CACHE="@sysconfdir@/zfs/zpool.cache"
25 if [ ! -c /dev/zfs ]; then
26 einfo "Checking if ZFS modules present"
27 if ! modinfo zfs > /dev/null 2>&1 ; then
28 eerror "$ZFS_MODULE not found. Is the ZFS package installed?"
32 einfo "Checking if zfs userspace tools present"
33 if [ ! -x $ZPOOL ]; then
34 eerror "$ZPOOL binary not found."
37 if [ ! -x $ZFS ]; then
38 eerror "$ZFS binary not found."
46 checksystem || return 1
48 # Delay until all required block devices are present.
51 if [ ! -c /dev/zfs ]; then
54 if [ $rv -ne 0 ]; then
55 eerror "Failed to load the $ZFS_MODULE module, check 'dmesg|tail'."
61 # Import all pools described by the cache file, and then mount
62 # all filesystem based on their properties.
63 if [ -f $ZPOOL_CACHE ]; then
64 einfo "Importing ZFS pools"
65 # as per fedora script, import can fail if all pools are already imported
66 # The check for $rv makes no sense...but someday, it will work right.
67 $ZPOOL import -c $ZPOOL_CACHE -aN 2>/dev/null || true
69 if [ $rv -ne 0 ]; then
70 eerror "Failed to import not-yet imported pools."
76 einfo "Mounting ZFS filesystems"
79 if [ $rv -ne 0 ]; then
80 eerror "Failed to mount ZFS filesystems."
85 einfo "Exporting ZFS filesystems"
88 if [ $rv -ne 0 ]; then
89 eerror "Failed to export ZFS filesystems."
100 ebegin "Unmounting ZFS filesystems"
103 if [ $rv -ne 0 ]; then
104 einfo "Some ZFS filesystems not unmounted"
107 # Don't fail if we couldn't umount everything. /usr might be in use.
114 # show pool status and list
115 $ZPOOL status && echo && $ZPOOL list