Previously we ran Linux on HP servers with HP OEM’ed QLogic HBA’s. One nice thing about that was that the HP driver pack containted a couple of nice support scripts (namely hp_rescan) – We used the HP drivers because the driver in the kernel (earlier on at least) did not support multi-pathing.

When we started using IBM xSeries servers we had the following configurations:

The problem with all configurations is that none of them sported anything like hp_rescan. So I wipped up a small script

#!/bin/bash
# $Id: rescan_hba.sh 48 2008-03-11 12:37:48Z ajo $

# This script will rescan all found FC HBAs for (new) LUNs
# Beware that it will generate failover events (in multipathd for
# instance)

if [ -f /usr/sbin/hp_rescan ]
 then
    echo "hp_rescan found - use that instead"
    exit 0
fi


for host in $(cd /sys/class/fc_host; ls -d host*)
 do
    echo "Rescanning $host"
    echo 1 > /sys/class/fc_host/$host/issue_lip
    sleep 5
    echo "- - -" > /sys/class/scsi_host/$host/scan
done

There may be more elegant ways of doing this and I’m not sure if issue_lip is necessary – but has been tested on quite a few servers including some busy Oracle servers. And even though it can create a lot of SCSI event on the logs it has not failed so far.