After inserted a new SCSI disk, you may need to scan disks on the SCSI host. On the other side; you grow the current disk, you may need to re-scan disk to show new size. Most of cloud providers do this using cloud agents. But there may be some cases where it doesn't work!

SCSI hosts

You can find SCSI hosts under /sys/class/scsi_host/.

ls -l /sys/class/scsi_host/

Example output is:

total 0
lrwxrwxrwx 1 root root 0 Sep 1 09:38 host0 -> ../../devices/pci0000:00/0000:00:04.0/virtio2/host0/scsi_host/host0
lrwxrwxrwx 1 root root 0 Sep 1 09:38 host1 -> ../../devices/pci0000:00/0000:00:01.1/ata1/host1/scsi_host/host1
lrwxrwxrwx 1 root root 0 Sep 1 09:38 host2 -> ../../devices/pci0000:00/0000:00:01.1/ata2/host2/scsi_host/host2

To scan example SCSI host which is host2:

echo "- - -" > "/sys/class/scsi_host/host2/scan"

SCSI devices

You can find SCSI devices under /sys/class/scsi_device/.

ls -l /sys/class/scsi_device/

Example output is:

total 0
lrwxrwxrwx 1 root root 0 Sep 1 09:38 0:0:0:0 -> ../../devices/pci0000:00/0000:00:04.0/virtio2/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0

To re-scan example SCSI device which is 0:0:0:0 on host0:

echo 1 > "/sys/class/scsi_device/0:0:0:0/device/rescan"

SCSI disks

You can check whether your disk is under SCSI device:

ls -l /sys/block

Example output is:

total 0
lrwxrwxrwx 1 root root 0 Sep 12 09:38 sda -> ../devices/pci0000:00/0000:00:04.0/virtio2/host0/target0:0:0/0:0:0:0/block/sda

You can see the disk under SCSI devices.

Conclusion

The following script reloads all SCSI hosts and devices and also SCSI disks:

#! /usr/bin/env bash

for h in $(find /sys/class/scsi_host/ -mindepth 1 -maxdepth 1)
do
  echo "$h"
  echo "- - -" > "$h/scan"
done

for h in $(find /sys/class/scsi_device/ -mindepth 1 -maxdepth 1)
do
  echo "$h"
  echo 1 > "$h/device/rescan"
done