Scan and Configure New LUNS on Redhat Linux (RHEL)

By Parthiban Ponnusamy

Found another useful thing on the web. This is the quick guide to rescan and configure newly added LUNS in Linux. 


To configure the newly added LUNS on RHEL:


# ls /sys/class/fc_host
 host0  host1  host2  host3

 fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l

 echo "1" > /sys/class/fc_host/host0/issue_lip

 echo "- - -" > /sys/class/scsi_host/host0/scan

 echo "1" > /sys/class/fc_host/host1/issue_lip

 echo "- - -" > /sys/class/scsi_host/host1/scan

 echo "1" > /sys/class/fc_host/host2/issue_lip

 echo "- - -" > /sys/class/scsi_host/host2/scan

 echo "1" > /sys/class/fc_host/host3/issue_lip

 echo "- - -" > /sys/class/scsi_host/host3/scan

 cat /proc/scsi/scsi | egrep -i 'Host:' | wc -l

 fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l

Alternatively, we can
run the re-scan-scsi script.

To scan new LUNs on Linux operating system which is using QLogic driver 

You need to find out driver proc file /proc/scsi/qlaXXX. 

For example on my system it is /proc/scsi/qla2300/0 

Once file is identified you need to type following command (login as the root
):
 
# echo "scsi-qlascan" > /proc/scsi/qla2300/0
 # cat /proc/scsi/qla2300/0

Now use the script rescan-scsi-bus.sh new LUN as a device. Run script as follows:
 
# ./rescan-scsi-bus.sh -l -w

The output of ls -l /sys/block/*/device should give you an idea about how each device is connected to the system. 

For Further Reading,
Linux, Quick HOWTO, SAN, Storage

My Profile PhotoAbout the Author

I'm Parthiban, An UNIX System Admin by Profession. I'm Experienced in Linux/Unix System Administration and Scripting. I have done lot of work on the infrastructure Mgmt side in Linux, UNIX and Windows system administration, Hardware, Storage and Data center. I'm blogging since 2008.
Follow Me On Twitter or On Facebook

{ 17 comments... read them below or add one }

Anonymous said...

Good one...

Anonymous said...

Nice Info. Thanks for sharing.

Parthiban Ponnusamy said...

Thanks for visiting and comment..!

Anonymous said...

gud one dude

Parthiban Ponnusamy said...

@Anony: Thanks for visit and comment

Sergio Pedraza Diaz said...

Excellent.. it works!!

Parthiban Ponnusamy said...

@Sergio

Thanks for your feedback..!

Anonymous said...

Nice share.. thank you

Parthiban Ponnusamy said...

Thanks

Anonymous said...

That saved me a reboot for a PROD....Thanks much!!!

Anonymous said...

how to identify newly added luns to a box

Arunabh said...

i used to reboot the server to discover newly added luns. Thanks alot Partibhan for providing such a good and simple procedure to scan luns. Thanks again...

Anonymous said...

Good work thanks

Anonymous said...

Really very useful. do you have doc for redhat cluster config

Parthiban Ponnusamy said...

Look at http://www.lazysystemadmin.com/2010/03/redhat-cluster-setup-guide.html

Anonymous said...

The rescan command did not work for me. The LUNs are presented, yet still unable to locate these:
# ./rescan-scsi-bus.sh
WARN: /usr/bin/sg_inq not present -- please install sg3_utils
or rescan-scsi-bus.sh might not fully work.
Host adapter 0 (hpsa) found.
Host adapter 1 (qla2xxx) found.
Host adapter 2 (qla2xxx) found.
Host adapter 3 (be2iscsi) found.
Host adapter 4 (be2iscsi) found.
Scanning SCSI subsystem for new devices
Scanning host 0 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs
Scanning for device 0 0 0 0 ...
OLD: Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: HP Model: LOGICAL VOLUME Rev: 3.66
Type: Direct-Access ANSI SCSI revision: 05
Scanning for device 0 3 0 0 ...
OLD: Host: scsi0 Channel: 03 Id: 00 Lun: 00
Vendor: HP Model: P410i Rev: 3.66
Type: RAID ANSI SCSI revision: 05
Scanning host 1 for all SCSI target IDs, all LUNs
Scanning for device 1 0 0 254 ...
OLD: Host: scsi1 Channel: 00 Id: 00 Lun: 254
Vendor: 3PARdata Model: SES Rev: 3111
Type: Enclosure ANSI SCSI revision: 05
..... [SNIP]...
Scanning for device 2 0 3 9 ...
OLD: Host: scsi2 Channel: 00 Id: 03 Lun: 09
Vendor: 3PARdata Model: VV Rev: 3111
Type: Direct-Access ANSI SCSI revision: 05
Scanning for device 2 0 3 10 ...
OLD: Host: scsi2 Channel: 00 Id: 03 Lun: 10
Vendor: 3PARdata Model: VV Rev: 3111
Type: Direct-Access ANSI SCSI revision: 05
Scanning for device 2 0 4 0 ...
OLD: Host: scsi2 Channel: 00 Id: 04 Lun: 00
Vendor: HP Model: Ultrium 5-SCSI Rev: Y5AZ
Type: Sequential-Access ANSI SCSI revision: 06
Scanning for device 2 0 5 0 ...
OLD: Host: scsi2 Channel: 00 Id: 05 Lun: 00
Vendor: HP Model: Ultrium 5-SCSI Rev: Y5AZ
Type: Sequential-Access ANSI SCSI revision: 06
Scanning host 3 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs
Scanning host 4 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs
0 new device(s) found.
0 device(s) removed.

Anonymous said...

Hi,

I am new to Scaning/Detecting Luns on Redhat Linux.

I know disk names line /dev/sda,/dev/sdb or /dev/had,/dev/hdb

Can you please let me know how the disk names comes after detecting the lun in Rhel5/6 with below commands?


# ls /sys/class/fc_host
host0 host1 host2 host3

echo "1" > /sys/class/fc_host/host0/issue_lip

echo "- - -" > /sys/class/scsi_host/host0/scan

echo "1" > /sys/class/fc_host/host1/issue_lip

echo "- - -" > /sys/class/scsi_host/host1/scan

echo "1" > /sys/class/fc_host/host2/issue_lip

echo "- - -" > /sys/class/scsi_host/host2/scan

echo "1" > /sys/class/fc_host/host3/issue_lip

echo "- - -" > /sys/class/scsi_host/host3/scan

Please let me Know.

Post a Comment

What do you think about this Article? Add your Opinion..!