function fix_stale_disk ()
{
echo_header
if grep -q -i offline /sys/block/*/device/state
then
#Checking for offline disks
echo "Linux discovered offline disks."
grep -l -i offline /sys/block/*/device/state
echo "Do you want to fix the offline disks? (y/n)"
read ans
if [[ "$ans" == "y" || "$ans" == 'Y' ]]
then
for block in `grep -l -i offline /sys/block/*/device/state | awk -F/ '{print $4}'`
do
status=""
echo -n "Deleting /dev/$block ..."
echo 1 > /sys/block/$block/device/delete
if [[ "$?" -eq "0" ]]
then
status="Done"
else
status="Failed"
fi
sleep 5
echo " $status"
done
echo ""
#Rescanning the disks.
for f in `ls -1 /sys/class/fc_host/*/issue_lip 2>/dev/null`
do
echo "Rescanning $f ..."
echo 1 > $f
sleep 5
done
else
echo "You have halted the operation."
exit 1
fi
else
echo "All disks are good."
fi
}
No comments:
Post a Comment