When building a Linux server, it is inevitable to map the storage to save any database and application files which require more storage space.
To add storage to the host, server has to be mapped with storage device by zoning the WWN of both host and storage in Fabric switch.
To request new LUN’s, Linux Admin has to share the server name and required LUN size to the SAN team to provision it.
Following article will help to find the WWN number of a Linux host.
Once the storage team has mapped the new LUN’s with the Linux host, new LUN can be discovered by scanning the storage LUN ID at the host end.
Scanning can be performed in two ways.
- Scan each FC host & SCSI host device using /sys class file.
- Run the “rescan-scsi-bus.sh” script to detect new disks.
Once scanned, New LUN will be visible under the “/dev/disk/by-id” directory.
ll /dev/disk/by-id total 0 lrwxrwxrwx 1 root root 10 Jul 9 17:52 scsi-60a98000486e542d4f5a2f47694d684b -> ../../sdah lrwxrwxrwx 1 root root 9 Jul 9 17:52 scsi-60a98000486e542d4f5a2f47694d684c -> ../../sdw . . lrwxrwxrwx 1 root root 10 Jul 9 17:52 scsi-60a98000486e542d4f5a2f47694d684d -> ../../sdjk lrwxrwxrwx 1 root root 10 Jul 9 17:52 scsi-60a98000486e542d4f5a2f47694d684e -> ../../sdaa lrwxrwxrwx 1 root root 9 Jul 9 17:52 scsi-60a98000486e542d4f5a2f47694d684f -> ../../sdh
Multipath command can also be used to see the LUN’s, if it is already configured in the host. Multipathing is mostly configured for critical applications which demands high availability and better performance.
multipath -ll 60a98000486e542d4f5a2f47694d684b dm-37 NETAPP,LUN C-Mode size=512G features='3 queue_if_no_path pg_init_retries 50' hwhandler='1 alua' wp=rw |-+- policy='round-robin 0' prio=50 status=active | |- 1:0:4:18 sdoe 128:416 active ready running | |- 0:0:4:18 sdpq 131:256 active ready running | |- 0:0:5:18 sdsr 135:496 active ready running | `- 1:0:5:18 sdsq 135:480 active ready running `-+- policy='round-robin 0' prio=10 status=enabled |- 1:0:1:18 sdfw 131:32 active ready running |- 1:0:0:18 sdci 69:96 active ready running |- 0:0:1:18 sdbz 68:208 active ready running |- 0:0:0:18 sds 65:32 active ready running |- 1:0:3:18 sdmd 69:336 active ready running |- 1:0:2:18 sdjj 8:464 active ready running |- 0:0:3:34 sdjt 65:368 active ready running `- 0:0:2:34 sdgi 131:224 active ready running
Scanning procedure works on Red Hat 6.x, 7.x, 8.x and 9.x (RHEL – Red Hat Enterprise Linux) and it’s derivatives such as CentOS and Oracle Linux.
Method-1: Scanning SCSI disks and LUN in Linux
‘sysfs‘ filesystem is a pseudo-file system which provides an interface to the kernel data structures.
Files under sysfs provides an information about devices, kernel modules, filesystems and other kernel components.
sysfs file system is commonly mounted at “/sys”. Typically, it is mounted automatically by the system.
Each scsi host device can be scanned using the echo command, as shown below.
echo "- - -" > /sys/class/scsi_host/host[n]/scan
Three dashes (- – – ) in the above command refers to wild card option which in turn rescan everything.
echo "c t l" > /sys/class/scsi_host/host[n]/scan
Values mentioned in the above wild card will scan the following parameters.
- c – Channel on the HBA
- t – SCSI target ID
- l – LUN ID
- n – HBA number
Run the below command to find all the host bus number in your system.
ls /sys/class/scsi_host host0 host1 host2
Once the host bus number has been verified, run the following command to discover new disks.
echo "- - -" > /sys/class/scsi_host/host0/scan echo "- - -" > /sys/class/scsi_host/host1/scan echo "- - -" > /sys/class/scsi_host/host2/scan
Above task can also be performed, by using “for loop” as a single command.
for host in `ls /sys/class/scsi_host`; do echo "Scanning $host...Completed"; echo "- - -" > /sys/class/scsi_host/$host/scan; done Scanning host0...Completed Scanning host1...Completed Scanning host2...Completed
LUN ID which has been detected in the server, can be verified by using ls command as below.
ls /dev/disk/by-id | grep -i "LUN ID"
Method-1(a): Scanning FC LUNs in Linux
Follow the below procedure to rescan the newly added FC LUNs.
To identify the number of HBA adapters, run. Note the number of hosts available on the server in order to scan them.
host0 host1 host2 host3
Run the command against each FC channel to scan the LUNs. Make a note, just replace with your actual FC host value instead.
echo "- - -" > /sys/class/fc_host/host0/issue_lip echo "- - -" > /sys/class/fc_host/host1/issue_lip echo "- - -" > /sys/class/fc_host/host2/issue_lip echo "- - -" > /sys/class/fc_host/host3/issue_lip
If you find many FC hosts, use the for loop to scan all at once.
for host in ls /sys/class/fc_host/;do echo "- - -" >/sys/class/fc_host/$host/issue_lip; done
Method-2: Detecting LUNs and SCSI disks in Linux
To use the rescan-scsi-bus.sh script, “sg3_utils” package has to be installed in the system. If not installed, run the following command to install it.
For RHEL/CentOS 6/7 systems, use the yum command to install sg3_utils.
yum install -y sg3_utils
For RHEL/CentOS 8 and Fedora systems, use the dnf command to install sg3_utils.
dnf install -y sg3_utils
New LUN’s can be scanned using the rescan-scsi-bus.sh script as follows.
This article can be referred whenever you find any difficulties in scanning or detecting any new LUN’s on Linux from the storage.
Kindly support us by sharing this article with wider circle.