Shell script to scan and detect newly connected scsi LUN in Linux

Posted: November 23, 2015 in Scan Disk, Shell Script

Script : scandisk.sh

#!/bin/bash

echo -e ” \nScan and Detect newly connected SCSI LUN\n ”
host=`ls -l /sys/class/scsi_host/ | grep -v total | awk ‘{print $9}’ | awk -F”host” ‘{print $2}’`
for i in $host
do
echo “Rescaning scsi host /sys/class/scsi_host/host$i”
echo “- – -” > /sys/class/scsi_host/host$i/scan
done
echo -e “\n All the SCSI LUN scanned Successfully…..\n”

 

Output : 

[root@autel ~]# ./scandisk.sh

Scan and Detect newly connected SCSI LUN

Rescaning scsi host /sys/class/scsi_host/host0
Rescaning scsi host /sys/class/scsi_host/host1
Rescaning scsi host /sys/class/scsi_host/host2

All the SCSI LUN scanned Successfully…..

[root@autel ~]#

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s