2 # Copyright 1999-2011 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4 # $Header: /var/cvsroot/gentoo-x86/sys-fs/zfs/files/zfs,v 0.9 2011/04/30 10:13:43 devsk Exp $
8 # bootmisc will log to /var which may be a different zfs than root.
11 keyword -lxc -openvz -prefix -vserver
15 ZPOOL="@sbindir@/zpool"
16 ZPOOL_CACHE="@sysconfdir@/zfs/zpool.cache"
20 if [ ! -c /dev/zfs ]; then
21 einfo "Checking if ZFS modules present"
22 if ! modinfo zfs > /dev/null 2>&1 ; then
23 eerror "$ZFS_MODULE not found. Is the ZFS package installed?"
27 einfo "Checking if zfs userspace tools present"
28 if [ ! -x $ZPOOL ]; then
29 eerror "$ZPOOL binary not found."
32 if [ ! -x $ZFS ]; then
33 eerror "$ZFS binary not found."
41 checksystem || return 1
43 # Delay until all required block devices are present.
46 if [ ! -c /dev/zfs ]; then
49 if [ $rv -ne 0 ]; then
50 eerror "Failed to load the $ZFS_MODULE module, check 'dmesg|tail'."
56 # Import all pools described by the cache file, and then mount
57 # all filesystem based on their properties.
58 if [ -f $ZPOOL_CACHE ]; then
59 einfo "Importing ZFS pools"
60 # as per fedora script, import can fail if all pools are already imported
61 # The check for $rv makes no sense...but someday, it will work right.
62 $ZPOOL import -c $ZPOOL_CACHE -aN 2>/dev/null || true
64 if [ $rv -ne 0 ]; then
65 eerror "Failed to import not-yet imported pools."
71 einfo "Mounting ZFS filesystems"
74 if [ $rv -ne 0 ]; then
75 eerror "Failed to mount ZFS filesystems."
80 einfo "Exporting ZFS filesystems"
83 if [ $rv -ne 0 ]; then
84 eerror "Failed to export ZFS filesystems."
95 ebegin "Unmounting ZFS filesystems"
98 if [ $rv -ne 0 ]; then
99 einfo "Some ZFS filesystems not unmounted"
102 # Don't fail if we couldn't umount everything. /usr might be in use.
109 # show pool status and list
110 $ZPOOL status && echo && $ZPOOL list