Skip to content

Commit

Permalink
contrib: add megaraid_sas unbind script
Browse files Browse the repository at this point in the history
  • Loading branch information
zdykstra committed May 1, 2024
1 parent 1b496a6 commit b7124bb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contrib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ review the scripts themselves for more thorough descriptions of their use.
early-setup hook, this facilitates, *e.g.*, multiple-slot keys for ZFS pools
that use native encryption.

- `megaraid-teardown.sh` - Unbind drivers for `megaraid_sas` devices, so that
they're available after a kexec. This is patterned after the XHCI teardown
script.

- `remote-ssh-build.sh` - This is a standalone script intended to wrap the
`zbm-builder.sh` image-builder script, incorporating a dropbear SSH server,
host keys and an `authorized_keys` file that permit remote access and pool
Expand Down
17 changes: 17 additions & 0 deletions contrib/megaraid-teardown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

#
# Configure this script as a user teardown.d hook
#

SYS_MEGARAID=/sys/bus/pci/drivers/megaraid_sas

# shellcheck disable=SC2231
for DEVPATH in ${SYS_MEGARAID}/????:??:??.?; do
[ -L "${DEVPATH}" ] || continue
DEVICE="${DEVPATH#"${SYS_MEGARAID}"/}"
echo "Tearing down Megaraid controller ${DEVICE}..."
echo "${DEVICE}" > ${SYS_MEGARAID}/unbind
echo "Resetting Megaraid controller ${DEVICE}..."
echo "1" > /sys/bus/pci/devices/${DEVICE}/reset
done

0 comments on commit b7124bb

Please sign in to comment.