3 # zfs This shell script takes care of starting (mount) and
4 # stopping (umount) zfs shares.
7 # description: ZFS is a filesystem developed by Sun, ZFS is a
8 # combined file system and logical volume manager
9 # designed by Sun Microsystems. Made available to Linux
10 # using SPL (Solaris Porting Layer) by zfsonlinux.org.
14 start) echo "$1ing ZFS filesystems"
16 # Delay until all required block devices are present.
19 if ! grep "zfs" /proc/modules > /dev/null; then
20 echo "ZFS kernel module not loaded yet; loading...";
21 if ! modprobe zfs; then
22 echo "Failed to load ZFS kernel module...";
27 if ! [ `uname -m` == "x86_64" ]; then
28 echo "Warning: You're not running 64bit. Currently native zfs in";
29 echo " linux is only supported and tested on 64bit.";
30 # should we break here? People doing this should know what they
31 # do, thus i'm not breaking here.
34 # mount the filesystems
35 while IFS= read -r -d $'\n' dev; do
36 mdev=$(echo "$dev" | awk '{ print $1; }')
37 echo -n "mounting $mdev..."
38 if zfs mount $mdev; then
43 done < <(zfs list -H);
48 stop) echo "$1ping ZFS filesystems"
50 if grep "zfs" /proc/modules > /dev/null; then
51 # module is loaded, so we can try to umount filesystems
52 while IFS= read -r -d $'\n' dev; do
53 mdev=$(echo "$dev" | awk '{ print $1 }');
54 echo -n "umounting $mdev...";
55 if zfs umount $mdev; then
60 # the next line is, because i have to reverse the
61 # output, otherwise it wouldn't work as it should
62 done < <(zfs list -H | tac);
64 # and finally let's rmmod the module
69 # module not loaded, no need to umount anything
75 restart) echo "$1ing ZFS filesystems"
80 *) echo "Usage: $0 {start|stop|restart}"