Well the other day I had to add a lot of LUN’s to a new system and one of the key elements is writting down the SCSI WWID when I add a LUN so I can tie that back to the storage. So i wrote a simple script to scan the SCSI bus identify new lun’s and provide their WWID via multipath. This will only work with some HBA’s and if your using Linux MPIO.
#!/bin/bash echo "- - -" > /sys/class/scsi_host/host0/scan echo "- - -" > /sys/class/scsi_host/host1/scan echo "- - -" > /sys/class/scsi_host/host2/scan echo "- - -" > /sys/class/scsi_host/host3/scan ls -altr /dev/sd* | tail -n1 | awk '{ print $10 }' \ | sed 's/\/dev\///g' | awk '{print "/sbin/multipath -v3 \ | grep " $1 " | grep undef"}' > out chmod 755 out ./out rm -f out