zfs/scripts/zfs.sh

75 lines
1.0 KiB
Bash
Raw Permalink Normal View History

2009-01-09 00:19:38 +00:00
#!/bin/bash
2009-01-09 00:20:25 +00:00
#
# A simple script to simply the loading/unloading the ZFS module stack.
2009-01-09 00:19:38 +00:00
basedir="$(dirname $0)"
SCRIPT_COMMON=common.sh
if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then
. "${basedir}/${SCRIPT_COMMON}"
else
echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
fi
2009-01-09 00:19:38 +00:00
PROG=zfs.sh
UNLOAD=
2009-01-09 00:19:38 +00:00
usage() {
cat << EOF
2009-01-09 00:20:25 +00:00
USAGE:
$0 [hvud] [module-options]
DESCRIPTION:
Load/unload the ZFS module stack.
2009-01-09 00:19:38 +00:00
OPTIONS:
2009-01-09 00:20:25 +00:00
-h Show this message
-v Verbose
-u Unload modules
-d Save debug log on unload
2009-01-09 00:19:38 +00:00
2009-01-09 00:20:25 +00:00
MODULE-OPTIONS:
Must be of the from module="options", for example:
2009-01-09 00:19:38 +00:00
$0 zfs="zfs_prefetch_disable=1"
$0 zfs="zfs_prefetch_disable=1 zfs_mdcomp_disable=1"
2009-01-09 00:19:38 +00:00
$0 spl="spl_debug_mask=0"
EOF
}
while getopts 'hvud' OPTION; do
case $OPTION in
h)
usage
exit 1
;;
v)
VERBOSE=1
2009-01-09 00:19:38 +00:00
;;
u)
UNLOAD=1
2009-01-09 00:19:38 +00:00
;;
d)
DUMP_LOG=1
2009-01-09 00:19:38 +00:00
;;
?)
usage
exit
;;
esac
done
if [ $(id -u) != 0 ]; then
die "Must run as root"
fi
if [ ${UNLOAD} ]; then
2009-01-09 00:19:38 +00:00
unload_modules
else
check_modules || die "${ERROR}"
2009-01-09 00:19:38 +00:00
load_modules "$@"
fi
exit 0