How to Scan Newly added Disks in Linux Easily

How to Scan Newly added Disks in Linux

This post will help you with How to Scan Newly added Disks in Linux Easily

If you are interested in learning, Request you to go through the below recommended tutorial.

As a Linux admin, we may come in a situation like, to scan new FC luns or to scan new SCSI Disk which are provided by Storage team. Its need to be scan from the Linux OS side without rebooting server.

How to Scan Newly added Disks in Linux like FC LUNS and SCSI Disks?

So How to scan new FC LUNS and SCSI disks in Linux without rebooting the server?

Here is a solution to scan new disk or Luns assigned to the server.

In Linux we can scan the LUNs using the script “rescan-scsi-bus.sh” or triggering some device host files with some values.

Follow the process to rescan the new added FC 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’

Thanks for reading our post. share with your friends. We appreciate your feedback, Leave your comments if any.

Support Us: Share with your friends and groups.

Stay connected with us on social networking sites, Thank you.
YouTube | Facebook | Twitter | Pinterest | Rss