VMware VM: Hot Add Virtual Disk

From time-to-time, I find myself needing to hot add a virtual disk to a VM and expand capacity. While the process has improved over time, I still occasionally run into issues on Linux. In the post, I will cover potential issues and provide a workaround.
VMware_icon_256x

To add a hard drive or network card to a running VM, go to the settings of the VM and add the appropriate device. Answer the prompts that follow and select OK to add the new resource. Once the task shows as completed, the resource has been added to the VM. Although the resource has been added to the VM, the VM may not see the new hardware without manual intervention.

  • On Windows VMs, go to the device manager or storage manager as appropriate and select scan for new devices. Once the new devices are discovered you can configure them as appropriate.
  • On Linux VMs, run a script similar to the following to discover the new hardware:
    echo "- - -" > /sys/class/scsi_host/host/scan

Unfortunately, when I ran the above script on a 64-bit Ubuntu VM running 10.04, it did not add the drive. Upon manually executing the commands, I received the following:

# > echo "- - -" > /sys/class/scsi_host/host1/scan
bash: /sys/class/scsi_host/host1/scan: cannot overwrite existing file
# > echo "- - -" > /sys/class/scsi_host/host0/scan
bash: /sys/class/scsi_host/host0/scan: cannot overwrite existing file
# > echo "- - -" > /sys/class/scsi_host/host3/scan
bash: /sys/class/scsi_host/host3/scan: No such file or directory

To confirm the drive has not be discovered, I ran:

# > cat /proc/scsi/scsi
Attached devices:Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
Type:   CD-ROM                           ANSI  SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: VMware   Model: Virtual disk     Rev: 1.0
Type:   Direct-Access                    ANSI  SCSI revision: 02
Host: scsi2 Channel: 00 Id: 01 Lun: 00
Vendor: VMware   Model: Virtual disk     Rev: 1.0
Host: scsi2 Channel: 00 Id: 01 Lun: 00
Vendor: VMware   Model: Virtual disk     Rev: 1.0
Type:   Direct-Access                    ANSI  SCSI revision: 02

The hard drive I had just added was the third hard drive for the VM so as you can see the drive was not being seen. Based on the information from the previous command, I attempted to manually add the drive by running:

# > echo "scsi add-single-device 0 0 2 0">/proc/scsi/scsi
bash: /proc/scsi/scsi: cannot overwrite existing file
# > echo "scsi add-single-device 2 0 2 0">/proc/scsi/scsi
bash: /proc/scsi/scsi: cannot overwrite existing file

Still, the hard drive was not be discovered. Running out of ideas, I installed a third-party tool by running: apt-get install scsitools. After installation, the tool can be run as follows:

# > rescan-scsi-bus.sh
Host adapter 0 (ata_piix) found.
Host adapter 1 (ata_piix) found.
Host adapter 2 (mptspi) found.
Scanning SCSI subsystem for new devices
Scanning host 0 channels 0 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning host 1 channels 0 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning for device 1 0 0 0 ...
OLD: Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
Type:   CD-ROM                           ANSI SCSI revision: 05
Report Luns command not supported (support mandatory in SPC-3)
Scanning for device 1 0 0 0 ...
OLD: Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
Type:   CD-ROM                           ANSI SCSI revision: 05
Scanning host 2 channels 0 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning for device 2 0 0 0 ...
OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: VMware   Model: Virtual disk     Rev: 1.0
Type:   Direct-Access                    ANSI SCSI revision: 02
Scanning for device 2 0 1 0 ...
OLD: Host: scsi2 Channel: 00 Id: 01 Lun: 00
Scanning for device 2 0 1 0 ...
OLD: Host: scsi2 Channel: 00 Id: 01 Lun: 00
Vendor: VMware   Model: Virtual disk     Rev: 1.0
Type:   Direct-Access                    ANSI SCSI revision: 02
Scanning for device 2 0 2 0 ...
NEW: Host: scsi2 Channel: 00 Id: 02 Lun: 00
Vendor: VMware   Model: Virtual disk     Rev: 1.0
Type:   Direct-Access                    ANSI SCSI revision: 02
0 new device(s) found.
0 device(s) removed.

As you can see, this tool was successfully able to discover the new hard drive. While I finally found a workaround to this problem, I am curious why the other methods did not work and if there is an easier way to hot add a hard drive to a running Ubuntu VM.

© 2015, Steve Flanders. All rights reserved.

Leave a Reply

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

Back To Top