summaryrefslogtreecommitdiffstats
path: root/scripts/load-zfs.sh
blob: 6ba111b1d0bd9d86f23296d6218d6d02cf700aa7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash

prog=load-zfs.sh
. ../.script-config

spl_options=$1
zpool_options=$2

spl_module=${SPLBUILD}/modules/spl/spl.ko
zlib_module=/lib/modules/${KERNELSRCVER}/kernel/lib/zlib_deflate/zlib_deflate.ko
zavl_module=${ZFSBUILD}/lib/libavl/zavl.ko
znvpair_module=${ZFSBUILD}/lib/libnvpair/znvpair.ko
zport_module=${ZFSBUILD}/lib/libport/zport.ko
zcommon_module=${ZFSBUILD}/lib/libzcommon/zcommon.ko
zpool_module=${ZFSBUILD}/lib/libzpool/zpool.ko
zctl_module=${ZFSBUILD}/lib/libdmu-ctl/zctl.ko
zpios_module=${ZFSBUILD}/lib/libzpios/zpios.ko

die() {
	echo "${prog}: $1" >&2
	exit 1
}

load_module() {
	echo "Loading $1"
	/sbin/insmod $* || die "Failed to load $1"
}

if [ $(id -u) != 0 ]; then
	die "Must run as root"
fi

if /sbin/lsmod | egrep -q "^spl|^zavl|^znvpair|^zport|^zcommon|^zlib_deflate|^zpool"; then
	die "Must start with modules unloaded"
fi

if [ ! -f ${zavl_module} ] ||
   [ ! -f ${znvpair_module} ] ||
   [ ! -f ${zport_module} ] ||
   [ ! -f ${zcommon_module} ] ||
   [ ! -f ${zpool_module} ]; then
	die "Source tree must be built, run 'make'"
fi

load_module ${spl_module} ${spl_options}
load_module ${zlib_module}
load_module ${zavl_module}
load_module ${znvpair_module}
load_module ${zport_module}
load_module ${zcommon_module}
load_module ${zpool_module} ${zpool_options}
load_module ${zctl_module}
load_module ${zpios_module}

sleep 1
echo "Successfully loaded ZFS module stack"

exit 0