Fearthepenguin.net

Diary of a Lazy SysAdmin

Skip to: Content | Sidebar | Footer

Solaris – Script to scan FiberChannel bus

Here is a script that I use to re-scan the FiberChannel bus for new or removed volumes on Solaris 10.

WARNING!: This script works for me, but use it at your own risk! Make sure you look through the script and make sure it doesn’t do anything that would be unusual on your system. I take no responsibility if you use this script and it erases all of your production data. :)

#!/bin/sh
# This will scan the Fiber Channel bus on Solaris servers
# using cfgadm and then run devfsadm -C.
# I *think* I've got it set up so that it will autodetect
# the controller # that the HBA is recognized as.
# Usually it's c2 and c4, but it might be different.

CONTROLLER="UNSET"
for CONTROLLER in `/usr/sbin/cfgadm -al | grep fc-fabric | grep connected | grep
 configured | awk '{print $1}'`; do
        if [ ${CONTROLLER} = "UNSET" ]; then
                echo ""
                echo "No Fiber HBA Controllers found."
                exit 1
        fi
        echo ""
        echo "Scanning FC Bus on Controller ${CONTROLLER}..."
        cfgadm -o force_update -c configure ${CONTROLLER}
done

echo " "
echo "Reconfiguring devices..."
/usr/sbin/devfsadm -C

echo ""
echo "FC Bus scan complete."

Write a comment