2010-08-26 22:22:58 +04:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# A simple script to simply the loading/unloading the ZFS module stack.
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
PROG=zfs.sh
|
|
|
|
UNLOAD=
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
cat << EOF
|
|
|
|
USAGE:
|
|
|
|
$0 [hvud] [module-options]
|
|
|
|
|
|
|
|
DESCRIPTION:
|
|
|
|
Load/unload the ZFS module stack.
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-h Show this message
|
|
|
|
-v Verbose
|
|
|
|
-u Unload modules
|
|
|
|
-d Save debug log on unload
|
|
|
|
|
|
|
|
MODULE-OPTIONS:
|
|
|
|
Must be of the from module="options", for example:
|
|
|
|
|
|
|
|
$0 zfs="zfs_prefetch_disable=1"
|
|
|
|
$0 zfs="zfs_prefetch_disable=1 zfs_mdcomp_disable=1"
|
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
while getopts 'hvud' OPTION; do
|
|
|
|
case $OPTION in
|
|
|
|
h)
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
v)
|
|
|
|
VERBOSE=1
|
|
|
|
;;
|
|
|
|
u)
|
|
|
|
UNLOAD=1
|
|
|
|
;;
|
|
|
|
d)
|
|
|
|
DUMP_LOG=1
|
|
|
|
;;
|
|
|
|
?)
|
|
|
|
usage
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $(id -u) != 0 ]; then
|
|
|
|
die "Must run as root"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ${UNLOAD} ]; then
|
2014-01-22 01:30:03 +04:00
|
|
|
kill_zed
|
2011-02-16 22:10:31 +03:00
|
|
|
umount -t zfs -a
|
2011-06-12 09:48:49 +04:00
|
|
|
stack_check
|
2010-08-26 22:22:58 +04:00
|
|
|
unload_modules
|
|
|
|
else
|
2011-06-12 09:48:49 +04:00
|
|
|
stack_clear
|
2010-08-26 22:22:58 +04:00
|
|
|
check_modules || die "${ERROR}"
|
2014-04-10 21:44:00 +04:00
|
|
|
load_modules "$@" || die "Failed to load modules"
|
|
|
|
wait_udev /dev/zfs 30 || die "'/dev/zfs' was not created"
|
2010-08-26 22:22:58 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|