blob: a022ee9a582f81f309b15fe205c20348037d84e6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
#!/usr/bin/openrc-run
# Copyright 1999-2011 Gentoo Foundation
# Released under the 2-clause BSD license.
# $Header: /var/cvsroot/gentoo-x86/sys-fs/zfs/files/zfs,v 0.9 2011/04/30 10:13:43 devsk Exp $
if [ -z "$init" ]; then
# Not interactive
grep -qE '(^|[^\\](\\\\)* )zfs=(off|no)( |$)' /proc/cmdline && exit 3
fi
depend()
{
# Try to allow people to mix and match fstab with ZFS in a way that makes sense.
if [ "$(mountinfo -s /)" = 'zfs' ]
then
before localmount
else
after localmount
fi
# bootmisc will log to /var which may be a different zfs than root.
before bootmisc logger
use mtab
keyword -lxc -openvz -prefix -vserver
}
ZFS="/usr/bin/zfs"
ZPOOL="/usr/bin/zpool"
ZPOOL_CACHE="/etc/zfs/zpool.cache"
ZFS_MODULE=zfs
checksystem() {
if [ ! -c /dev/zfs ]; then
einfo "Checking if ZFS modules present"
if ! modinfo zfs > /dev/null 2>&1 ; then
eerror "$ZFS_MODULE not found. Is the ZFS package installed?"
return 1
fi
fi
einfo "Checking if zfs userspace tools present"
if [ ! -x $ZPOOL ]; then
eerror "$ZPOOL binary not found."
return 1
fi
if [ ! -x $ZFS ]; then
eerror "$ZFS binary not found."
return 1
fi
return 0
}
start() {
ebegin "Starting ZFS"
checksystem || return 1
# Delay until all required block devices are present.
udevadm settle
if [ ! -c /dev/zfs ]; then
modprobe $ZFS_MODULE
rv=$?
if [ $rv -ne 0 ]; then
eerror "Failed to load the $ZFS_MODULE module, check 'dmesg|tail'."
eend $rv
return $rv
fi
fi
# Import all pools described by the cache file, and then mount
# all filesystem based on their properties.
if [ -f $ZPOOL_CACHE ]; then
einfo "Importing ZFS pools"
# as per fedora script, import can fail if all pools are already imported
# The check for $rv makes no sense...but someday, it will work right.
$ZPOOL import -c $ZPOOL_CACHE -aN 2>/dev/null || true
rv=$?
if [ $rv -ne 0 ]; then
eerror "Failed to import not-yet imported pools."
eend $rv
return $rv
fi
fi
einfo "Mounting ZFS filesystems"
$ZFS mount -a
rv=$?
if [ $rv -ne 0 ]; then
eerror "Failed to mount ZFS filesystems."
eend $rv
return $rv
fi
einfo "Exporting ZFS filesystems"
$ZFS share -a
rv=$?
if [ $rv -ne 0 ]; then
eerror "Failed to export ZFS filesystems."
eend $rv
return $rv
fi
eend 0
return 0
}
stop()
{
ebegin "Unmounting ZFS filesystems"
$ZFS umount -a
rv=$?
if [ $rv -ne 0 ]; then
einfo "Some ZFS filesystems not unmounted"
fi
# Don't fail if we couldn't umount everything. /usr might be in use.
eend 0
return 0
}
status()
{
# show pool status and list
$ZPOOL status && echo && $ZPOOL list
}
|