Scan for new hotplug added disks

  • Written by
    Herman Bos
  • Published on

If you add new disks to a virtual machine you don’t have to reboot to be able to use them.

I assume this works the same for normal hotswappable disks as well but that just doesn’t happen too often these days. Didn’t test for all drivers/use cases but the example below is in a VMWARE environment. It has to be handled as scsi by the kernel obviously.

check for current disks:

# lsscsi
[1:0:0:0]    cd/dvd  NECVMWar VMware IDE CDR10 1.00  /dev/sr0
[2:0:0:0]    disk    VMware   Virtual disk     1.0   /dev/sda
[2:0:1:0]    disk    VMware   Virtual disk     1.0   /dev/sdb

disks are on ¨host 2¨ so rescan host 2:

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

new disk is detected and available for use:

# lsscsi
[1:0:0:0]    cd/dvd  NECVMWar VMware IDE CDR10 1.00  /dev/sr0
[2:0:0:0]    disk    VMware   Virtual disk     1.0   /dev/sda
[2:0:1:0]    disk    VMware   Virtual disk     1.0   /dev/sdb
[2:0:2:0]    disk    VMware   Virtual disk     1.0   /dev/sdc

Back to overview Newer post: probook 4510s / high fan speed Older post: mysql / show procedure / grant