Redhat Linux – How to dynamically add LUN's to Qlogic HBA

Dynamically adding LUN’s to Qlogic HBA on Linux:

1. Make sure that newly configured LUN’s are properly configured and mapped to correct HBA’s

2. If you have installed SANsurfer GUI/CLI, make sure newly added LUN’s are visible from these tools

3. For each QLogic HBA installed in the system, do the following:

a) Determine the host ID (H) associated with the HBA. Each installed HBA has a numeric filename that is the host identifier.

/bin/ls /proc/scsi/qla2300

b) Rescan for all the LUNs on all the ports.
H is the host identifier associated with HBA.

# /bin/echo  scsi-qlascan  > /proc/scsi/qla2300/H

c)  Determine the target ID (T) associated with the new LUN.
This file lists the ID:LUN numbers recognized by the QLA driver. T is the
target ID value.

/bin/cat /proc/scsi/qla2300/H

d) Add the LUN to HBA.
H is the host identifier associated with the HBA;
T is the target identifier obtained in Step c; and L is the LUN identifier.

/bin/echo  scsi add-single-device H 0 T L  > /proc/scsi/scsi

4. Use the command “/sbin/fdisk -l” to verify if the newly added LUN is visible to the OS


5. Partition the disk attached from new lun ( procedure )

Find below example illustrating addition of a newly mapped T4 LUN on Red Hat Linux using QLA driver version 7.07.04

1) Determine host ID

# /bin/ls /proc/scsi/qla2300/2

2)  Re-scan for LUN’s on both HBA’s

# /bin/echo  scsi-qlascan  > /proc/scsi/qla2300/2

3) Verify newly mapped LUN’s

# /bin/cat /proc/scsi/qla2300/2
QLogic PCI to Fibre Channel Host Adapter for QLA2342:
Firmware version:  3.03.19, Driver version 7.07.04
Entry address = f88ae060
HBA: QLA2312 , Serial# F05179
Request Queue = 0x377e0000, Response Queue = 0x377d0000
Request Queue count= 512, Response Queue count= 512
Total number of active commands = 0
Total number of interrupts = 35
Total number of active IP commands = 0
Total number of IOCBs (used/max) = (0/600)
Total number of queued commands = 0
Device queue depth = 0x20
Number of free request entries = 510
Number of mailbox timeouts = 0
Number of ISP aborts = 0
Number of loop resyncs = 2
Number of retries for empty slots = 0
Number of reqs in pending_q= 0, retry_q= 0, done_q= 0, scsi_retry_q= 0
Host adapter:loop state= <READY>, flags= 0x820813
Dpc flags = 0x0
MBX flags = 0x0
SRB Free Count = 4096
Link down Timeout = 000
Port down retry = 030
Login retry count = 030
Commands retried with dropped frame(s) = 0
Configured characteristic impedence: 50 ohms
Configured data rate: 1-2 Gb/sec auto-negotiate
SCSI Device Information:

SCSI LUN Information:
(Id:Lun)  * – indicates lun is not registered with the OS.
( 0: 0): Total reqs 1, Pending reqs 0, flags 0x0*, 0:0:81,
( 0:15): Total reqs 0, Pending reqs 0, flags 0x0*, 0:0:81,

Note “*” in the above outputs, which indicates LUN as not registered
with OS, hence not visible to OS.

4) Register the new LUN’s with OS

# /bin/echo  scsi add-single-device 2 0 0 15 > /proc/scsi/scsi

5) verify from OS using “fdisk -l”

# /sbin/fdisk -l

Disk /dev/sda: 36.4 GB, 36420075008 bytes
255 heads, 63 sectors/track, 4427 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot    Start       End    Blocks   Id  System
/dev/sda1   *         1        13    104391   83  Linux
/dev/sda2            14      4173  33415200   83  Linux
/dev/sda3          4174      4427   2040255   82  Linux swap

Disk /dev/sdb: 5372 MB, 5372116992 bytes
255 heads, 63 sectors/track, 653 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1       653   5245191   83  Linux

In the above output ‘sdb’ is the new LUN, which was partitioned earlier.




I have started ( aka in 2009 as my own personal reference blog, and later sometime i have realized that my leanings might be helpful for other unixadmins if I manage my knowledge-base in more user friendly format. And the result is today's' You can connect me at -

1 Response

  1. September 17, 2015

    […] Read – How to dynamically add LUN’s to Qlogic HBA […]

What is in your mind, about this post ? Leave a Reply

  Our next learning article is ready, subscribe it in your email

What is your Learning Goal for Next Six Months ? Talk to us