[4980] in linux-scsi channel archive
Re: Howto: rescan scsi bus after a hot swap ??
daemon@ATHENA.MIT.EDU (Kurt Garloff)
Fri Oct 23 08:01:02 1998
Date: Fri, 23 Oct 1998 08:32:49 +0200
From: Kurt Garloff <garloff@kg1.ping.de>
To: Chris Atenasio <chrisa@ultranet.com>,
Hardware Stuff <mrfixit@clouddancer.com>
Cc: linux-scsi@vger.rutgers.edu, ncr53c810@Colorado.EDU
Mail-Followup-To: Chris Atenasio <chrisa@ultranet.com>,
Hardware Stuff <mrfixit@clouddancer.com>,
linux-scsi@vger.rutgers.edu, ncr53c810@Colorado.EDU
In-Reply-To: <Pine.LNX.4.05.9810222019260.6133-100000@chris.atenasio.net>; from Chris Atenasio on Thu, Oct 22, 1998 at 08:22:55PM -0400
--NzB8fVQJ5HfG6fxh
Content-Type: text/plain; charset=us-ascii
On Thu, Oct 22, 1998 at 08:22:55PM -0400, Chris Atenasio wrote:
> >From /usr/src/linux/drivers:
>
> /*
> * Usage: echo "scsi add-single-device 0 1 2 3" >/proc/scsi/scsi
> * with "0 1 2 3" replaced by your "Host Channel Id Lun".
> * Consider this feature BETA.
> * CAUTION: This is not for hotplugging your peripherals. As
> * SCSI was not designed for this you could damage your
> * hardware !
The usual warnings apply ...
I append a script to automagically rescan the SCSI bus.
Regards,
--
Kurt Garloff <K.Garloff@ping.de> (Dortmund, FRG)
PGP key on http://student.physik.uni-dortmund.de/homepages/garloff
Unix IS user friendly - it's just selective about who its friends are!
--NzB8fVQJ5HfG6fxh
Content-Type: text/plain; charset=us-ascii
Content-Description: rescan-scsi-bus.sh
Content-Disposition: attachment; filename="rescan-scsi-bus.sh"
#!/bin/bash
# Skript to rescan SCSI bus, using the
# scsi add-single-device mechanism
# (w) 98/03/19 Kurt Garloff <K.Garloff@ping.de> (c) GNU GPL
# Return hosts. /proc/scsi/HOSTADAPTER/? must exist
findhosts ()
{
hosts=
for name in /proc/scsi/*/?; do
name=${name#/proc/scsi/}
if test ! $name = scsi
then hosts="$hosts ${name#*/}"
echo "Host adapter ${name#*/} (${name%/*}) found."
fi
done
}
# Test if SCSI device $host $channen $id $lun exists
# Outputs description from /proc/scsi/scsi, returns new
testexist ()
{
grepstr="scsi$host Channel: 0$channel Id: 0*$id Lun: 0$lun"
new=`cat /proc/scsi/scsi|grep -e"$grepstr"`
if test ! -z "$new"
then cat /proc/scsi/scsi|grep -e"$grepstr"
cat /proc/scsi/scsi|grep -A2 -e"$grepstr"|tail -2|pr -o4 -l1
fi
}
# Perform search (scan $host)
dosearch ()
{
for channel in $channelsearch; do
for id in $idsearch; do
for lun in $lunsearch; do
new=
devnr="$host $channel $id $lun"
echo "Scanning for device $devnr ..."
printf "OLD: "
testexist
if test -z "$new"
then printf "\rNEW: "
echo "scsi add-single-device $devnr" >/proc/scsi/scsi
testexist
if test -z "$new"; then printf "\r\x1b[A"; else let found+=1; fi
fi
done
done
done
}
# main
if test @$1 = @--help -o @$1 = @-h
then
echo "Usage: rescan-scsi-bus.sh [-l] [-w] [-c] [host [host ...]]"
echo " -l activates scanning for LUNs 0 .. 7 [default: 0]"
echo " -w enables scanning for device IDs 0 .. 15 [def.: 0 .. 7]"
echo " -c enables scanning of channels 0 1 [default: 0]"
echo " If hosts are given, only these are scanned [def.: all]"
exit 0
fi
# defaults
lunsearch="0"
idsearch="0 1 2 3 4 5 6 7"
channelsearch="0"
# Scan options
opt="$1"
while test ! -z "$opt" -a -z "${opt##-*}"; do
opt=${opt#-}
case "$opt" in
l) lunsearch="0 1 2 3 4 5 6 7" ;;
w) idsearch="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15" ;;
c) channelsearch="0 1" ;;
*) echo "Unknown option -$opt !" ;;
esac
shift
opt="$1"
done
# Hosts given ?
if test @$1 = @; then findhosts; else hosts=$*; fi
declare -i found=0
for host in $hosts; do dosearch; done
echo "$found new device(s) found. "
--NzB8fVQJ5HfG6fxh--
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.rutgers.edu