Rescan for new disks in Linux virtual machines

When new disk is added to the Linux virtual machine, sometimes the machine does not detect it.

If you know which SCSI host the disk is added simply issue this command:
echo "- - -" > /sys/class/scsi_host/hostX/scan

Replace ‘hostX’ with appropriate host.

If unsure which SCSI host then quick and dirty way is simply scan all of them:

for host in /sys/class/scsi_host/*; do echo "- - -" > $host/scan; done

To rescan for disk size change do following:

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

Where ‘sdX’ is the disk that has been resized.

Leave a Reply

Your email address will not be published. Required fields are marked *