Dec 20, 2011

Online LUN Detection in RHEL

Online LUN Detection in RedHat Enterprise Linux

Release:
RedHat Enterprise Linux

Problem:
Detect Newly assigned LUN in RHEL without reboot the server

Solution:

1)       Install the required packages

                                # yum install sysfsutils sg3_utils

2)       We need the below parameters to rescan the scsi bus

                                H – HBA Number
                                C – Channel on the HBA
                                T – SCSI target id
                                L – LUN id

3)       We can get the above said parameters using the different command, for me I am using “systool” and “sg_map” command

            # systool -c fc_host -v
           
            Class Device = "host3"
            Class Device path = "/sys/class/fc_host/host3"
            port_name = "0x2100001b32882e82"

Note : In the above sample output class device path is “host3”. So 3 is the HBA number, if dual channel HBA means like the above host4 also will displayed. Here port name is the HBA's wwn id.

            # systool -c fc_transport -v
           
            Class Device = "0:0"
            Class Device path = "/sys/class/fc_transport/target3:0:0"
            port_name = "0x200400a0b84889b5"
                               
Note: In the above command output, class device path is “3:0:0”, that is in the order of “HBA number:channel on HBA:SCSI Target id”  (H:C:T). Here port name is the storage's wwpn id.

            # sg_map -x

            /dev/sg0  0 0 0 0  0
            /dev/sg1  0 0 1 0  0
            /dev/sg2  0 1 0 0  0  /dev/sda
            /dev/sg3  3 0 0 0  0
            /dev/sg4  3 0 0 31  0
            /dev/sg5  3 0 1 0  0  /dev/sdb
            /dev/sg6  3 0 1 1  0  /dev/sdc
            /dev/sg7  3 0 2 0  0  /dev/sdd
            /dev/sg8  3 0 2 1  0  /dev/sde
                                           
Note: In the above command output, first four digits as represents “H C T L” also known as Host, Bus, Target, Lun  (H B T L). From this we can identify how many luns are already mapped.

4)       Now rescan the SCSI bus using the said parameters

                                # echo “C T L” > /sys/class/scsi_host/HostH/scan

Note: If u are having dual channel HBA card means scan both the HBA numbers using the above command .

5)       Now check with the fdisk command, whether the LUN is detected or  not. If not means use the below command

                                # echo “1” > /sys/class/fc_host/hostH/issue_lip

Note: The above command instruct the driver to rediscover the remote ports. LIP (Loop Initialization  Protocol).

6)       Now confirm with the fdisk command and use the LUN as usual.





No comments: