]> git.proxmox.com Git - mirror_zfs-debian.git/blob - scripts/zfs.sh
Merge tag 'upstream/0.6.4.2'
[mirror_zfs-debian.git] / scripts / zfs.sh
1 #!/bin/bash
2 #
3 # A simple script to simply the loading/unloading the ZFS module stack.
4
5 basedir="$(dirname $0)"
6
7 SCRIPT_COMMON=common.sh
8 if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then
9 . "${basedir}/${SCRIPT_COMMON}"
10 else
11 echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
12 fi
13
14 PROG=zfs.sh
15 UNLOAD=
16
17 usage() {
18 cat << EOF
19 USAGE:
20 $0 [hvud] [module-options]
21
22 DESCRIPTION:
23 Load/unload the ZFS module stack.
24
25 OPTIONS:
26 -h Show this message
27 -v Verbose
28 -u Unload modules
29 -d Save debug log on unload
30
31 MODULE-OPTIONS:
32 Must be of the from module="options", for example:
33
34 $0 zfs="zfs_prefetch_disable=1"
35 $0 zfs="zfs_prefetch_disable=1 zfs_mdcomp_disable=1"
36
37 EOF
38 }
39
40 while getopts 'hvud' OPTION; do
41 case $OPTION in
42 h)
43 usage
44 exit 1
45 ;;
46 v)
47 VERBOSE=1
48 ;;
49 u)
50 UNLOAD=1
51 ;;
52 d)
53 DUMP_LOG=1
54 ;;
55 ?)
56 usage
57 exit
58 ;;
59 esac
60 done
61
62 if [ $(id -u) != 0 ]; then
63 die "Must run as root"
64 fi
65
66 if [ ${UNLOAD} ]; then
67 kill_zed
68 umount -t zfs -a
69 stack_check
70 unload_modules
71 else
72 stack_clear
73 check_modules || die "${ERROR}"
74 load_modules "$@" || die "Failed to load modules"
75 wait_udev /dev/zfs 30 || die "'/dev/zfs' was not created"
76 fi
77
78 exit 0