Scan new FC LUNS and SCSI disks in Linux

How to scan new FC LUNS and SCSI disks in Redhat Linux without rebooting the server? Most of the Linux beginners have wondering how to do this and this article will be for them.It may look like very simple as we perform this in daily operation to scan luns but system has many work to do in background when you execute storage scanning commands. Redhat says this type of scan can be distributive,since it can cause delays while I/O operation timeout and remove devices unexpectedly from OS.So perform this scan when really you want to scan the disks and LUNS.

1. Identify the existing disks

fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-|type|identifier'

2. Identify the number of HBA adapters

systool -c fc_host -v

or 


ls /sys/class/fc_host
 host0

Note the number of hosts available in the server.

3. Use the below command to scan the LUNs

echo "1" > /sys/class/fc_host/host0/issue_lip
 echo "- - -" > /sys/class/scsi_host/host0/scan

If you have more number of hosts file under the directory /sys/class/fc_host, then use the command for each hosts file by replacing the “host0”.

From Redhat Linux 5.4 onwards, redhat introduced “/usr/bin/rescan-scsi-bus.sh” script to scan all the SCSI bus and update the SCSI layer to reflect new devices.

We can also use the “rescan-scsi-bus.sh” script to detect new LUNs without rebooting the server.
This script is available with sg3-utils package. So install the sg3-utils package.

yum install sg3_utils
rescan-scsi-bus.sh

4. Verify the Detected disks from fdisk again

fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-|type|identifier'

Follow the process to rescan the new added SCSI Disks:

1. Identify the existing disks

fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-|type|identifier'

2. Identify the number of SCSI Controllers detected

ls /sys/class/scsi_host/
 host0

Note the number of hosts available in the server.

3. Scan the SCSI Disk for each hosts

echo "- - -" > /sys/class/scsi_host/host0/scan

If you have more number of hosts file under the directory /sys/class/scsi_host, then use the command for each hosts file by replacing the “host0”.

4. Verify the Detected disks from fdisk again

fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-|type|identifier'

The step by step guide to scan FC LUNS on Solaris.