Dynamically discovering disk volume in RedHat

This is one of those “note to myself” posts. Discovering a new volume on a Linux server is little cruder than it is in Solaris.

Obviously, you have to provision a LUN on the storage. I have never tried it but I suppose you could use /usr/bin/rescan-scsi-bus.sh script from sg3_utils package.

Anyway, then you need to figure out which HBA the new disk should be accessible through. If your HBA has multiple channels, you will need to know which channel the new disk should be accessible through.

Taking a concrete example, this server had one, single channel HBA with an existing disk, and with a new disk zoned for the HBA. This was RedHat 5.9 server.

[root@db0001 root]#echo "0 1 0" > /sys/class/scsi_host/host0/scan
[root@db0001 root]#

The above command initiated scan of first HBA (host0), channel 0, target 1 for a new LUN. Since the scan was successful the following appeared in syslog:

[root@db0001 root]# tail /var/log/messages
Apr 16 11:46:23 db0001 kernel: sdb: Write Protect is off
Apr 16 11:46:23 db0001 kernel: sdb: cache data unavailable
Apr 16 11:46:23 db0001 kernel: sdb: assuming drive cache: write through
Apr 16 11:46:23 db0001 kernel: SCSI device sdb: 10485760 512-byte hdwr sectors (5369 MB)
Apr 16 11:46:23 db0001 kernel: sdb: Write Protect is off
Apr 16 11:46:23 db0001 kernel: sdb: cache data unavailable
Apr 16 11:46:23 db0001 kernel: sdb: assuming drive cache: write through
Apr 16 11:46:23 db0001 kernel:  sdb: unknown partition table
Apr 16 11:46:23 db0001 kernel: sd 0:0:1:0: Attached scsi disk sdb
Apr 16 11:46:23 db0001 kernel: sd 0:0:1:0: Attached scsi generic sg1 type 0

In the above example, if you had a dual channel HBA (dual port FC HBA) and no existing disk attached to the second channel, to see a new disk on the second channel, you would do:

[root@db0001 root]#echo "1 0 0" > /sys/class/scsi_host/host0/scan
[root@db0001 root]#

Similarly, if you had two single channel HBAs, with new disk zoned for the second HBA, which already had one disk (disk 0) attached to it, you would do:

[root@db0001 root]#echo "0 1 0" > /sys/class/scsi_host/host1/scan
[root@db0001 root]#

The whole x:x:x:x nomenclature is little confusing with some people using bus to refer to a channel, etc. You can think of it as adapter:port:target:lun

Posted on April 28, 2013 at 16:18 by somedude · Permalink
In: centos, fibre channel, linux, linux tips, redhat, san, storage

Leave a Reply