]> git.proxmox.com Git - mirror_zfs-debian.git/blob - scripts/zfs.sh
Merge branch 'upstream'
[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 $0 spl="spl_debug_mask=0"
37
38 EOF
39 }
40
41 while getopts 'hvud' OPTION; do
42 case $OPTION in
43 h)
44 usage
45 exit 1
46 ;;
47 v)
48 VERBOSE=1
49 ;;
50 u)
51 UNLOAD=1
52 ;;
53 d)
54 DUMP_LOG=1
55 ;;
56 ?)
57 usage
58 exit
59 ;;
60 esac
61 done
62
63 if [ $(id -u) != 0 ]; then
64 die "Must run as root"
65 fi
66
67 if [ ${UNLOAD} ]; then
68 umount -t zfs -a
69 stack_check
70 unload_modules
71 else
72 stack_clear
73 check_modules || die "${ERROR}"
74 load_modules "$@"
75 wait_udev /dev/zfs 30
76 fi
77
78 exit 0