Thursday, January 8, 2015

How to scan new FC LUNS and SCSI disks in Linux ?



Overview:

While Working on the Linux boxes , some times linux admin have to scan new storage or LUNs assign to the server from the Storage team. In Redhat linux & CentOS we can scan the LUNs either using the script ‘rescan-scsi-bus.sh’ or using the ‘/sys/class’ files without rebooting the server.

In My scenario I have 4 FC (Fiber Channel) ports on the server , and new Luns are assigned on these ports. Follow the below steps to detect or scan new Luns :

Method:1
First Check the Fibre channels using the below Command :

# ls /sys/class/fc_host
host0  host1  host2  host3
Now Scan New luns using below Commands:

# 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


Method:2
The sg3_utils package provides the rescan-scsi-bus.sh script, this script scans new luns on redhat linux and CentOS. So to use this script first we have to install sg3_utils rpm.

# yum install sg3_utils
# ./rescan-scsi-bus.sh

Now the Check the newly discovered disks using ‘fdisk -l’  command or by ‘multipath -l’ command if configured.





NOTE: The three values stand for channel, SCSI target ID, and LUN. The dashes act as wildcards meaning "rescan everything"









OR



                                    Scanning FC-LUN’s in Redhat Linux


1.First find out how many disks are visible in “fdisk -l” .
# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l 

2.Find out how many host bus adapter configured in the Linux box.you can use “systool -fc_host -v” to verify available FC in the system.

#ls /sys/class/fc_host
host3  host4


In this case,you need to scan host3 & host4 HBA.

3.If the system virtual memory is too low ,then do not proceed further.If you have enough free virtual memory,then you can proceed with below command to scan new LUNS.


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

Note: You need to monitor the “issue_lip” in /var/log/messages to determine when the scan will complete.This operation is an asynchronous operation.


4.Verify if the new LUN is visible or not by counting the available disks.
# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l 


If any new LUNS added ,then you can see more count is more then before scanning the LUNS.

                                     Scanning SCSI DISKS in Redhat Linux

1.Finding the existing disk from fdisk.
[root@mylinz1 ~]# fdisk -l |egrep '^Disk' |egrep -v 'dm-'
Disk /dev/sda: 21.5 GB, 21474836480 bytes

2.Find out how many SCSI controller configured.
[root@mylinz1 ~]# ls /sys/class/scsi_host/host
host0 host1 host2
In this case,you need to scan host0,host1 & host2.

3.Scan the SCSI disks using below command.
[root@mylinz1 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@mylinz1 ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
[root@mylinz1 ~]# echo "- - -" > /sys/class/scsi_host/host2/scan

4.Verify if the new disks are visible or not.
[root@mylinz1 ~]# fdisk -l |egrep '^Disk' |egrep -v 'dm-'
Disk /dev/sda: 21.5 GB, 21474836480 bytes
Disk /dev/sdb: 1073 MB, 1073741824 bytes
Disk /dev/sdc: 1073 MB, 1073741824 bytes


No comments:

Post a Comment