Backtrack:  
 
by lunarg on September 18th 2019, at 12:02

When adding a new disk to a live system (e.g. a linux VM), the new disk may not always show up. Additionally, when resizing a disk through the hypervisor, the VM may not always immediately have the new size available for use. Luckily, you can trigger a rescan of the SCSI bus through the sysfs system.

For this to work, you'll need to have shell and root access to the server/VM.

Adding a new disk

Modern linux kernels automatically detect the addition of a disk, but in case it doesn't, you can trigger a rescan of a specific (virtual) SCSI controller:

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

Replace hostX with the number of the SCSI controller, where host0 is the first, host1 is the second, etc. You can do an ls /sys/class/scsi_host to see which controllers are available. If you're uncertain on which controller the new disk was connected to, it doesn't hurt to run a rescan on all available controllers.

Increasing size of an existing disk

When resizing a disk, the linux kernel usually doesn't pick up the change right away. You can trigger a rescan of the specific disk device:

echo "1" > /sys/class/block/sdX/device/rescan

Replace sdX with the exact device node of the disk to rescan. Which this is depends on the type of disk (and moreover, the driver that's backing the SCSI/SATA/PATA controller), but modern linux kernels almost always refer to disk devices as if it was a SCSI disk, meaning that sda is the first disk, sdb the second, and so on.