Scan and Configure New LUNS on Redhat Linux (RHEL)

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. 

Share this

Related Posts

Previous
Next Post »

16 comments

Write comments
Anonymous
October 7, 2010 at 12:18 AM delete

Nice Info. Thanks for sharing.

Reply
avatar
October 7, 2010 at 12:21 AM delete

Thanks for visiting and comment..!

Reply
avatar
March 18, 2011 at 4:27 PM delete

@Anony: Thanks for visit and comment

Reply
avatar
June 13, 2011 at 6:53 PM delete

@Sergio

Thanks for your feedback..!

Reply
avatar
Anonymous
June 26, 2011 at 7:09 AM delete

Nice share.. thank you

Reply
avatar
Anonymous
July 1, 2011 at 8:03 PM delete

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

Reply
avatar
Anonymous
February 27, 2012 at 12:34 AM delete

how to identify newly added luns to a box

Reply
avatar
Arunabh
October 18, 2012 at 7:30 PM delete

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...

Reply
avatar
Anonymous
October 21, 2012 at 7:43 AM delete

Good work thanks

Reply
avatar
Anonymous
February 18, 2013 at 7:07 PM delete

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

Reply
avatar
February 19, 2013 at 12:21 AM delete

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

Reply
avatar
Anonymous
March 26, 2013 at 7:25 PM delete

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.

Reply
avatar
Anonymous
June 10, 2016 at 3:33 PM delete

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.

Reply
avatar

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