You are on page 1of 4

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

/dev/sg1

0 0 1 0

/dev/sg2

0 1 0 0

/dev/sg3

3 0 0 0

/dev/sg4

3 0 0 31

/dev/sg5

3 0 1 0

/dev/sdb

/dev/sg6

3 0 1 1

/dev/sdc

/dev/sg7

3 0 2 0

/dev/sdd

/dev/sg8

3 0 2 1

/dev/sde

/dev/sda

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.

To check the HBA card on the Linux Box


#lspci vv | less

Difference between WWN and WWPN?


A WWPN (world wide port name) is the unique identifier for a fibre channel
port where a WWN (world wide name) the unique identifier for the node
itself.
Find wwn numbers
If our Linux box is connected to one or more SAN switch via Fibre HBA
cards. So it becomes very important to the Storage Team that they assign
the storage to the connect Servers via WWN numbers of Fibre HBA Cards.
# systool -c fc_host -v | grep "port_name"
Sample Output :
port_name
= "0x5001438001347fdc"
port_name
= "0x5001438001347fde"
port_name
= "0x50014380013471f0"
port_name
= "0x50014380013471f2"
systool command is provided by the rpm package sysfsutils
Alternate Method :
# cat /sys/class/scsi_host/hostN/device/fc_host/hostN/port_name
Where N is the number of device for your fiber HBAs.

Find the below command to list the HBA Interfaces on your system
[root@server99 ~]# lspci -nn|grep -i hba
05:00.0 Fibre Channel [0c04]: QLogic Corp. ISP2532-based 8Gb Fibre Channel
to PCI Express HBA [1077:2532] (rev 02)
05:00.1 Fibre Channel [0c04]: QLogic Corp. ISP2532-based 8Gb Fibre Channel
to PCI Express HBA [1077:2532] (rev 02)

Scanning FC-LUNs 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
host0 host1
In this case,you need to scan host0 & host1 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/host0/issue_lip
# echo "1" > /sys/class/fc_host/host1/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
[root@mylinz1 ~]# echo "- [root@mylinz1 ~]# echo "- [root@mylinz1 ~]# echo "- -

below command.
-" > /sys/class/scsi_host/host0/scan
-" > /sys/class/scsi_host/host1/scan
-" > /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

You might also like