]>
Commit | Line | Data |
---|---|---|
c9c0d073 BB |
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" | |
c9c0d073 BB |
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 | |
ea04106b | 67 | kill_zed |
b9f6a490 | 68 | umount -t zfs -a |
10715a01 | 69 | stack_check |
c9c0d073 BB |
70 | unload_modules |
71 | else | |
10715a01 | 72 | stack_clear |
c9c0d073 | 73 | check_modules || die "${ERROR}" |
ea04106b AX |
74 | load_modules "$@" || die "Failed to load modules" |
75 | wait_udev /dev/zfs 30 || die "'/dev/zfs' was not created" | |
c9c0d073 BB |
76 | fi |
77 | ||
78 | exit 0 |