]> git.proxmox.com Git - mirror_zfs-debian.git/blame - scripts/zfs.sh
Merge branch 'upstream'
[mirror_zfs-debian.git] / scripts / zfs.sh
CommitLineData
c9c0d073
BB
1#!/bin/bash
2#
3# A simple script to simply the loading/unloading the ZFS module stack.
4
5basedir="$(dirname $0)"
6
7SCRIPT_COMMON=common.sh
8if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then
9. "${basedir}/${SCRIPT_COMMON}"
10else
11echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
12fi
13
14PROG=zfs.sh
15UNLOAD=
16
17usage() {
18cat << EOF
19USAGE:
20$0 [hvud] [module-options]
21
22DESCRIPTION:
23 Load/unload the ZFS module stack.
24
25OPTIONS:
26 -h Show this message
27 -v Verbose
28 -u Unload modules
29 -d Save debug log on unload
30
31MODULE-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
38EOF
39}
40
41while 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
61done
62
63if [ $(id -u) != 0 ]; then
64 die "Must run as root"
65fi
66
67if [ ${UNLOAD} ]; then
b9f6a490 68 umount -t zfs -a
10715a01 69 stack_check
c9c0d073
BB
70 unload_modules
71else
10715a01 72 stack_clear
c9c0d073
BB
73 check_modules || die "${ERROR}"
74 load_modules "$@"
2c4834f8 75 wait_udev /dev/zfs 30
c9c0d073
BB
76fi
77
78exit 0