]> git.proxmox.com Git - mirror_zfs-debian.git/blame - scripts/zfs.sh
Add dpkg-dev to Depends of zfs-dkms (Closes: #900714)
[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
cae5b340 5basedir=$(dirname "$0")
c9c0d073
BB
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
cae5b340 14# shellcheck disable=SC2034
c9c0d073
BB
15PROG=zfs.sh
16UNLOAD=
17
18usage() {
19cat << EOF
20USAGE:
21$0 [hvud] [module-options]
22
23DESCRIPTION:
24 Load/unload the ZFS module stack.
25
26OPTIONS:
27 -h Show this message
28 -v Verbose
29 -u Unload modules
c9c0d073
BB
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"
c9c0d073
BB
36
37EOF
38}
39
cae5b340 40while getopts 'hvu' OPTION; do
c9c0d073
BB
41 case $OPTION in
42 h)
43 usage
44 exit 1
45 ;;
46 v)
cae5b340 47 # shellcheck disable=SC2034
c9c0d073
BB
48 VERBOSE=1
49 ;;
50 u)
51 UNLOAD=1
52 ;;
c9c0d073
BB
53 ?)
54 usage
55 exit
56 ;;
57 esac
58done
59
cae5b340 60if [ "$(id -u)" != 0 ]; then
c9c0d073
BB
61 die "Must run as root"
62fi
63
64if [ ${UNLOAD} ]; then
ea04106b 65 kill_zed
b9f6a490 66 umount -t zfs -a
10715a01 67 stack_check
c9c0d073
BB
68 unload_modules
69else
10715a01 70 stack_clear
c9c0d073 71 check_modules || die "${ERROR}"
ea04106b
AX
72 load_modules "$@" || die "Failed to load modules"
73 wait_udev /dev/zfs 30 || die "'/dev/zfs' was not created"
c9c0d073
BB
74fi
75
76exit 0