From b7124bbd6a89fd517039e88a4c1193286cdbeee5 Mon Sep 17 00:00:00 2001 From: Zach Dykstra Date: Wed, 1 May 2024 09:01:54 -0500 Subject: [PATCH] contrib: add megaraid_sas unbind script --- contrib/README.md | 4 ++++ contrib/megaraid-teardown.sh | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100755 contrib/megaraid-teardown.sh diff --git a/contrib/README.md b/contrib/README.md index d873d98d1..82a3438ee 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -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 diff --git a/contrib/megaraid-teardown.sh b/contrib/megaraid-teardown.sh new file mode 100755 index 000000000..b6087b105 --- /dev/null +++ b/contrib/megaraid-teardown.sh @@ -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