Encontrando seu dispositivo do robô de fitas [Finding Autochanger Device]

Encontrando seu dispositivo do robô de fitas [Finding Autochanger Device] 1

Dependendo do seu sistema, o robô de fitas pode, nem sempre, ser criado como /dev/st0, já que a ordem dos dispositivos SCSI pode mudar quando o servidor é reinicializado. Por exemplo, o robô pv132t (Dell Tape Library) estava representado por /dev/sg10, mas, agora, está no /dev/sg7, devido à ordem de descobrimento de dispositivos na SAN.

Apesar de não acontecer sempre, é inconveniente e difícil de rastrear. Existe um script que pode solucionar este problema. Segue:

#! /bin/bash -x
# Shell script to create the /dev/changer symlink to the correct device. This
is necessary
# because the /dev/sg* devices can (and do) change their targets upon reboot.

if [ -z $CREATECHANGERATTEMPTS ] ; then
CREATECHANGERATTEMPTS=0
fi

if [ $CREATECHANGERATTEMPTS -gt 1 ] ; then
echo "$0: error. Could not determine the /dev/sg* device connected to
the autochanger. /dev/changer not created."
exit 1
else
CREATECHANGERATTEMPTS=$((CREATECHANGERATTEMPTS + 1))
export CREATECHANGERATTEMPTS

if [ -e /dev/changer -a ! -h /dev/changer ]; then
echo "$0: error. /dev/changer exists but is not a symlink"
exit 1
fi

rm -f /dev/changer

# Walk through the /dev/sg* devices, running the mtx command. Upon
success, create
# the link

for device in /dev/sg*
do
mtx -f $device status 1> /dev/null 2>&1
# mtx -f $device status 1> /tmp/create_changer.out 2>
/dev/create_changer.errs
if [ $? = 0 ] ; then
ln -s $device /dev/changer
exit 0
fi
done

# We can only get here if the attempt failed...in that case...try:
#
# force the HBA to rescan the devices
#
# adding any devices that aren't registered with the OS
#
# do a SCSI reset on those devices

# Collect the initial sg_map, so that we can determine any new devices
sgmapBEFORE=`sg_map | cut -f1 -d" "`

# Find the correct host number for the HBA:
hostnum=`cd /proc/scsi/qla2300; ls [0-9]*`
bus=0

# force a rescan
echo "scsi-qlascan" > /proc/scsi/qla2300/$hostnum

# Find all the devices that are not registered with the OS:
grep "*" /proc/scsi/qla2300/$hostnum | grep flags | while read line
do
id=`echo $line | sed -e "s/:.*//" -e "s/.* //"`
lun=`echo $line | sed -e "s/).*//" -e "s/.* //"`
echo "scsi add-single-device $hostnum $bus $id $lun " >
/proc/scsi/scsi
done

sgmapAFTER=`sg_map | cut -f1 -d" "`

sgmapADDL=`echo $sgmapBEFORE $sgmapAFTER | tr " " "12" | sort | uniq
-u`

if [ -z $sgmapADDL ] ; then
echo "No new /dev/sg devices created"
exit 1
fi

for dev in $sgmapADDL
do
sg_reset $dev
done

# Now, re-run this script
$0
fi

Depending on your system, the changer device may not always be at /dev/sg0, as the SCSI device ordering can change each time the system is booted. For example, pv132t (Dell Tape Library) was on /dev/sg10, but it’s on /dev/sg7 now (for exemple), due to the device discovery order on SAN.

While this doesn’t happen all the time, it’s very inconvenient and difficult to catch. There is a script to help with this issue, right above.

Disponível em: pt-brPortuguês

Deixe uma resposta