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
|
|
|
|
2009-01-16 20:06:25 +00:00
|
|
|
. ./common.sh
|
|
|
|
PROG=zfs.sh
|
2009-01-09 00:19:38 +00:00
|
|
|
|
|
|
|
KMOD=/lib/modules/${KERNELSRCVER}/kernel
|
2009-01-16 20:06:25 +00:00
|
|
|
KERNEL_MODULES=( \
|
2009-01-09 00:19:38 +00:00
|
|
|
$KMOD/lib/zlib_deflate/zlib_deflate.ko \
|
|
|
|
)
|
|
|
|
|
2009-01-16 20:06:25 +00:00
|
|
|
SPL_MODULES=( \
|
2009-07-10 18:37:30 +00:00
|
|
|
${SPLBUILD}/spl/spl.ko \
|
2009-01-09 00:19:38 +00:00
|
|
|
)
|
|
|
|
|
2009-01-16 20:06:25 +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 \
|
2009-01-09 21:31:16 +00:00
|
|
|
${MODDIR}/zfs/zfs.ko \
|
2009-01-09 00:19:38 +00:00
|
|
|
)
|
|
|
|
|
2009-01-16 20:06:25 +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:
|
2009-01-16 20:06:25 +00:00
|
|
|
Must be of the from module="options", for example:
|
2009-01-09 00:19:38 +00:00
|
|
|
|
2009-01-09 21:31:16 +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
|
|
|
|
}
|
|
|
|
|
2009-01-16 20:06:25 +00:00
|
|
|
UNLOAD=
|
2009-01-09 00:19:38 +00:00
|
|
|
|
|
|
|
while getopts 'hvud' OPTION; do
|
|
|
|
case $OPTION in
|
|
|
|
h)
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
v)
|
2009-01-16 20:06:25 +00:00
|
|
|
VERBOSE=1
|
2009-01-09 00:19:38 +00:00
|
|
|
;;
|
|
|
|
u)
|
2009-01-16 20:06:25 +00:00
|
|
|
UNLOAD=1
|
2009-01-09 00:19:38 +00:00
|
|
|
;;
|
|
|
|
d)
|
2009-01-16 20:06:25 +00:00
|
|
|
DUMP_LOG=1
|
2009-01-09 00:19:38 +00:00
|
|
|
;;
|
|
|
|
?)
|
|
|
|
usage
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2009-01-16 20:06:25 +00:00
|
|
|
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
|
2009-01-16 20:06:25 +00:00
|
|
|
check_modules || die "${ERROR}"
|
2009-01-09 00:19:38 +00:00
|
|
|
load_modules "$@"
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|