zfs/scripts/zfs.sh

94 lines
1.4 KiB
Bash
Raw 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. It should probably be considered a first step towards
# a full ZFS init script when that is needed.
#
2009-01-09 00:19:38 +00:00
. ./common.sh
PROG=zfs.sh
2009-01-09 00:19:38 +00:00
KMOD=/lib/modules/${KERNELSRCVER}/kernel
KERNEL_MODULES=( \
2009-01-09 00:19:38 +00:00
$KMOD/lib/zlib_deflate/zlib_deflate.ko \
)
SPL_MODULES=( \
2009-07-10 18:37:30 +00:00
${SPLBUILD}/spl/spl.ko \
2009-01-09 00:19:38 +00:00
)
ZFS_MODULES=( \
2009-01-09 00:19:38 +00:00
${MODDIR}/avl/zavl.ko \
${MODDIR}/nvpair/znvpair.ko \
${MODDIR}/unicode/zunicode.ko \
${MODDIR}/zcommon/zcommon.ko \
${MODDIR}/zfs/zfs.ko \
2009-01-09 00:19:38 +00:00
)
MODULES=( \
${KERNEL_MODULES[*]} \
${SPL_MODULES[*]} \
${ZFS_MODULES[*]} \
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
}
UNLOAD=
2009-01-09 00:19:38 +00:00
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