How to scan SCSI disks and storage FC luns in Linux ?

In Linux, we can scan for new SCSI disks’ LUN or FC LUNs in real time without rebooting the server.

For this we need to I.) reset the FC or SCSI bus and then II.) re-scan the new LUNs attached.

1. Scanning new FC LUNs in Centos or Redhat Linux or RHEL.

a. Get the visible disks on system.

[root@nglinux ~]# fdisk -l | grep ^Disk | egrep -v "dm-|identifier" 
Disk /dev/sdb: 8589 MB, 8589934592 bytes
Disk /dev/sda: 34.4 GB, 34359738368 bytes
[root@nglinux ~]# 

b. Check the available FC host channel.

[root@nglinux ~]# ls /sys/class/fc_host/
host0 
[root@nglinux ~]# 

Now we need to scan host0 HBA for the new LUNs.

c. Reset the bus by using LIP(Loop Initiation protocol) and scan for new devices by echoing “—“(just like controller, target and disk in Unix).

[root@nglinux ~]# echo "1" > /sys/class/fc_host/host0/issue_lip
[root@nglinux ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@nglinux ~]# 

We can monitor the “issue_lip” messages in /var/log/messages file to determine if the scan is complete.

d. Scan the disks again if new disk is detected.

[root@nglinux ~]# fdisk -l | grep ^Disk | egrep -v "dm-|identifier" 
Disk /dev/sdb: 8589 MB, 8589934592 bytes
Disk /dev/sda: 34.4 GB, 34359738368 bytes
[root@nglinux ~]# 


2. Scanning new SCSI LUNs in Centos or Redhat Linux or RHEL.

a. Get the total number of disks available.

[root@nglinux ~]# fdisk -l | grep ^Disk | egrep -v "dm-|identifier" 
Disk /dev/sdb: 8589 MB, 8589934592 bytes
Disk /dev/sda: 34.4 GB, 34359738368 bytes
[root@nglinux ~]# 

b. Find out number of scsi hosts available.

[root@nglinux ~]# ls /sys/class/scsi_host/
host0  host1  host2  host3
[root@nglinux ~]# 

c. Scan all four targets using below command.

[root@nglinux ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@nglinux ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
[root@nglinux ~]# echo "- - -" > /sys/class/scsi_host/host2/scan
[root@nglinux ~]# echo "- - -" > /sys/class/scsi_host/host3/scan

d. Verify if new disks is available.

[root@nglinux ~]# fdisk -l | grep ^Disk | egrep -v "dm-|identifier" 
Disk /dev/sdb: 8589 MB, 8589934592 bytes
Disk /dev/sda: 34.4 GB, 34359738368 bytes

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments