Suppose you have added a new hard disk to your Linux OS running on any Virtual Environment which in my case is VMware workstation. Once added the new hard drive, generally the changes won't reflect unless you reboot the Guest OS.
But what if you are in no position to reboot the Gues Linux OS?
Solution:
In the below path you can find a list of host symlinks pointing to the iscsi device configured on your Linux box.
[root@varuntest ~]# ls -l /sys/class/scsi_host/
total 0
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host0 -> ../../devices/pci0000:00/0000:00:07.1/host0/scsi_host/host0
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host1 -> ../../devices/pci0000:00/0000:00:07.1/host1/scsi_host/host1
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host10 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host10/scsi_host/host10
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host11 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host11/scsi_host/host11
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host12 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host12/scsi_host/host12
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host13 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host13/scsi_host/host13
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host14 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host14/scsi_host/host14
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host15 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host15/scsi_host/host15
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host16 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host16/scsi_host/host16
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host17 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host17/scsi_host/host17
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host18 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host18/scsi_host/host18
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host19 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host19/scsi_host/host19
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host2 -> ../../devices/pci0000:00/0000:00:10.0/host2/scsi_host/host2
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host20 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host20/scsi_host/host20
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host21 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host21/scsi_host/host21
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host22 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host22/scsi_host/host22
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host23 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host23/scsi_host/host23
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host24 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host24/scsi_host/host24
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host25 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host25/scsi_host/host25
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host26 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host26/scsi_host/host26
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host27 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host27/scsi_host/host27
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host28 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host28/scsi_host/host28
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host29 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host29/scsi_host/host29
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host3 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host3/scsi_host/host3
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host30 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host30/scsi_host/host30
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host31 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host31/scsi_host/host31
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host32 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host32/scsi_host/host32
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host4 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host4/scsi_host/host4
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host5 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host5/scsi_host/host5
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host6 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host6/scsi_host/host6
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host7 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host7/scsi_host/host7
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host8 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host8/scsi_host/host8
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host9 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host9/scsi_host/host9
[root@varuntest ~]#
Here "- - -" defines the three values stored inside host*/scan i.e. channel number, SCSI target ID, and LUN values. We are simply replacing the values with wild cards so that it can detect new changes attached to the Linux box. This procedure will add LUNs, but not remove them.
But what if you are in no position to reboot the Gues Linux OS?
Solution:
In the below path you can find a list of host symlinks pointing to the iscsi device configured on your Linux box.
[root@varuntest ~]# ls -l /sys/class/scsi_host/
total 0
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host0 -> ../../devices/pci0000:00/0000:00:07.1/host0/scsi_host/host0
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host1 -> ../../devices/pci0000:00/0000:00:07.1/host1/scsi_host/host1
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host10 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host10/scsi_host/host10
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host11 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host11/scsi_host/host11
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host12 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host12/scsi_host/host12
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host13 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host13/scsi_host/host13
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host14 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host14/scsi_host/host14
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host15 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host15/scsi_host/host15
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host16 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host16/scsi_host/host16
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host17 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host17/scsi_host/host17
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host18 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host18/scsi_host/host18
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host19 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host19/scsi_host/host19
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host2 -> ../../devices/pci0000:00/0000:00:10.0/host2/scsi_host/host2
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host20 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host20/scsi_host/host20
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host21 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host21/scsi_host/host21
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host22 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host22/scsi_host/host22
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host23 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host23/scsi_host/host23
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host24 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host24/scsi_host/host24
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host25 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host25/scsi_host/host25
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host26 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host26/scsi_host/host26
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host27 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host27/scsi_host/host27
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host28 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host28/scsi_host/host28
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host29 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host29/scsi_host/host29
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host3 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host3/scsi_host/host3
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host30 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host30/scsi_host/host30
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host31 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host31/scsi_host/host31
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host32 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host32/scsi_host/host32
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host4 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host4/scsi_host/host4
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host5 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host5/scsi_host/host5
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host6 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host6/scsi_host/host6
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host7 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host7/scsi_host/host7
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host8 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host8/scsi_host/host8
lrwxrwxrwx. 1 root root 0 Jan 16 07:10 host9 -> ../../devices/pci0000:00/0000:00:11.0/0000:02:05.0/host9/scsi_host/host9
[root@varuntest ~]#
But to detect a new hard drive attached you need to first get your host bus number used which you can get by using below command.
# grep mpt /sys/class/scsi_host/host?/proc_name
You should get a output like below.
[root@varuntest ~]# grep mpt /sys/class/scsi_host/host?/proc_name
/sys/class/scsi_host/host2/proc_name:mptspi
[root@varuntest ~]#
So as you see your host2 is the relevant files where you need to reset the storage buffer values. Run the below command.
# echo "- - -" > /sys/class/scsi_host/host2/scan
Once done verify if you can see the new hard drive which in my case worked very fine as see below.
[root@varuntest ~]# fdisk -l /dev/sde
Disk /dev/sde: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
[root@varuntest ~]#