When you are running RedHat Enterprise Linux 5, 6, and 7 series system with DM-Multipath and the software iSCSI initiator, you can discover new LUNs by rescanning the iSCSI service on the host.
Rescanning the service will display all the newly created LUNs that have been mapped to the host. In this guide, I will show commands to scan and detect (outputs to check) new luns attached to the Centos/RHEL server.
To scan new FC LUNS and SCSI disks in Linux, you can use the echo script command for a manual scan that doesn't require a system reboot. But, from Redhat Linux 5.4 onwards, Redhat introduced /usr/bin/rescan-scsi-bus.sh script to scan all the LUNs and update the SCSI layer to reflect new devices.
Check the number of attached disks
You use the below commands to identify existing LUNs and how to add newly mapped LUNs to Linux.
You can use the echo command to scan each scsi host device as below. Now to rescan the bus, use the following command
# echo "- - -" > /sys/class/scsi_host/host0/scan
The three dash ("- - -") of the command act as wildcards meaning rescan everything. Remember that the three values normally stand for channel, SCSI target ID, and LUN.
# echo "c t l" > /sys/class/scsi_host/hosth/scan
where
h is the HBA number
c is the channel on the HBA
t is the SCSI target ID
l is the LUN.
If you don't have the host bus number, you must list all the existing host bus number on your system with the command
# ls /sys/class/scsi_host
host0 host1 host2
Then you will scan every iscsi disk found and scan after every scanning if the new disk was detected. It means
If you have too many hosts (from host0 to host20 for example), you can use the command below
# for host in `ls /sys/class/scsi_host/`;do
echo "- - -" >/sys/class/scsi_host/${host}/scan;
done
or you can try (this one for Fibre Channel)
# for host in `ls /sys/class/fc_host/`; do
echo "1" >/sys/class/fc_host/${host}/issue_lip;
done
Can devices be rescanned in Linux OS without reloading the Linux driver?
There is a procedure which forces the driver to rescan the targets and to allow a new device which is to be added. This triggers the driver to initiate a LUN discovery process.
To force a rescan from the command line, type the following command:
# echo "scsi-qlascan" > /proc/scsi/
where,
- = qla2100, qla2200, qla2300 (2.4 kernel drivers) or qla2xxx (2.6 kernel drivers) - = the instance number of the HBA
After executing this command, force the SCSI mid layer to do its own scan and build the device table entry for the new device by typing the following command:
The scanning must be done in the above-mentioned order; first the driver (qla2300/qla2200 driver, etc.) and then the Linux SCSI mid-layer (i.e. OS scan).
2. Scan lun with multipath/powermt
You can check the current multipath setup using multipath or powermt command.
If EMC powerpath is installed, check the disk/multipath status as below:
# powermt display dev=all | more
Pseudo name=emcpowerb
CLARiiON ID=APM00080503154 [cl10083]
Logical device ID=6006016023041F003AB6ED708885DD11 [LUN 3]
state=alive; policy=CLAROpt; priority=0; queued-IOs=0
Owner: default=SP A, current=SP A Array failover mode: 1
==============================================================================
---------------- Host --------------- - Stor - -- I/O Path - -- Stats ---
### HW Path I/O Paths Interf. Mode State Q-IOs Errors
==============================================================================
3 qla2xxx sde SP A2 active alive 0 1
3 qla2xxx sdh SP B3 active alive 0 0
6 qla2xxx sdk SP A3 active alive 0 1
6 qla2xxx sdn SP B2 active alive 0 0
..............................
..............................
==============================================================================
---------------- Host --------------- - Stor - -- I/O Path - -- Stats ---
### HW Path I/O Paths Interf. Mode State Q-IOs Errors
==============================================================================
3 qla2xxx sdd SP A2 active alive 0 1
3 qla2xxx sdg SP B3 active alive 0 0
6 qla2xxx sdj SP A3 active alive 0 1
6 qla2xxx sdm SP B2 active alive 0 0
Multipath daemon will automatically add attached devices if it's configured properly. For powermt, we need to run below command manually.
# powermt config
3. Using Script
You can rescan using the SCSI rescan script which will detect new luns and add it to your server automatically. You can find this script in sg3_utils package.
# /us/bin/rescan-scsi-bus.sh -a
Scanning SCSI subsystem for new devices
Scanning host 0 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNs
..................
..................
1 new or changed device(s) found.
[0:0:5:0]
0 remapped or resized device(s) found.
0 device(s) removed.
Conclusion
For storage (Netapp,equallogic) that use iscsi target, command iscsiadm -m session --rescan could be used to rescan when new lun added to the target. I would recommend always to use vendor-specific script or tools to scan Luns.
I hope you have enjoyed reading and let us know if you found any other method to scan storage disk devices.
If this resource helped you, let us know your care by a Thanks Tweet.
Did you find this article helpful?
We are glad you liked the article. Share with your friends.
About The Author
Bobbin Zachariah
Bobbin is a seasoned IT professional with over two decades of experience. He has excelled in roles such as a computer science instructor, Linux system engineer, and senior analyst. Currently, he thrives in DevOps environments, focusing on optimizing efficiency and delivery in AWS Cloud infrastructure. Bobbin holds certifications in RHEL, CCNA, and MCP, along with a Master's degree in computer science. In his free time, he enjoys playing cricket, blogging, and immersing himself in the world of music.
Comments