Discovering new LUNs on Linux

Voiced by Amazon Polly

Discovering new LUNs on Linux without rebooting

When you add new LUNs in VMWare to a Linux server you will not see them right away.  A reboot will solve this problem, however, rebooting is not always possible.  If this is a production server, you will have to schedule the reboot and coordinate it with the team.  This takes time.  An easy way to get around this is to do a manual rescan of the iscsi bus.

Viewing what iscsi hosts are available

ls -l /sys/class/scsi_host
total 0
lrwxrwxrwx. 1 root root 0 Nov 15 15:04 host0 -> ../../devices/pci0000:00/0000:00:07.1/ata1/host0/scsi_host/host0
lrwxrwxrwx. 1 root root 0 Nov 15 15:04 host1 -> ../../devices/pci0000:00/0000:00:07.1/ata2/host1/scsi_host/host1
lrwxrwxrwx. 1 root root 0 Nov 15 15:04 host2 -> ../../devices/pci0000:00/0000:00:10.0/host2/scsi_host/host2
lrwxrwxrwx. 1 root root 0 Nov 15 15:04 host3 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:01.0/host3/scsi_host/host3

Finding new LUNs

This command will show you all the hosts available on the system.  If you wish to see which ones are new, we run the following command:

grep mpt /sys/class/scsi_host/host?/proc_name

Performing the manual scan

The results of the grep command show us host2 and host3.  We can then use this information to do a manual scan.

echo "- - -" > /sys/class/scsi_host/host2/scan
echo "- - -" > /sys/class/scsi_host/host3/scan
You will not see anything returned however if you issue an lsblk or format -l you will see the new LUNs that had been added to the VM by your virtualization team, all without needing to reboot.
fdisk -l

<truncated results>

Disk /dev/sde: 1095.2 GB, 1095216660480 bytes, 2139095040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

I hope this article helps you out when you need it.  For myself, this was helpful as I needed to expand LVM volumes and I did not want to reboot the servers beforehand.  If you have any questions or comments, please feel free to write them in the comments section below.


Ivan Windon – RHCSA


Ivan Windon

Ivan Windon is a Senior Technical Support Engineer at Red Hat, where Ivan supports Red Hat Satellite. Ivan is actively engaged in Cloud Technologies with AWS, Google, and Azure. Ivan has extensive experience with Linux and Windows administration, DNS, Networking, IDM, and Security. In his free time, he enjoys being with his wife and two children. The family enjoys hiking, and traveling when able. His favorite locations are Yosemite NPS, and San Francisco, California.

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: