Skip to content

Commit b7124bb

Browse files
committed
contrib: add megaraid_sas unbind script
1 parent 1b496a6 commit b7124bb

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

contrib/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ review the scripts themselves for more thorough descriptions of their use.
2828
early-setup hook, this facilitates, *e.g.*, multiple-slot keys for ZFS pools
2929
that use native encryption.
3030

31+
- `megaraid-teardown.sh` - Unbind drivers for `megaraid_sas` devices, so that
32+
they're available after a kexec. This is patterned after the XHCI teardown
33+
script.
34+
3135
- `remote-ssh-build.sh` - This is a standalone script intended to wrap the
3236
`zbm-builder.sh` image-builder script, incorporating a dropbear SSH server,
3337
host keys and an `authorized_keys` file that permit remote access and pool

contrib/megaraid-teardown.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
#
4+
# Configure this script as a user teardown.d hook
5+
#
6+
7+
SYS_MEGARAID=/sys/bus/pci/drivers/megaraid_sas
8+
9+
# shellcheck disable=SC2231
10+
for DEVPATH in ${SYS_MEGARAID}/????:??:??.?; do
11+
[ -L "${DEVPATH}" ] || continue
12+
DEVICE="${DEVPATH#"${SYS_MEGARAID}"/}"
13+
echo "Tearing down Megaraid controller ${DEVICE}..."
14+
echo "${DEVICE}" > ${SYS_MEGARAID}/unbind
15+
echo "Resetting Megaraid controller ${DEVICE}..."
16+
echo "1" > /sys/bus/pci/devices/${DEVICE}/reset
17+
done

0 commit comments

Comments
 (0)