Monday, April 22, 2013

Converting IDE Virtual Disk to SCSI

Today, I was asked to expand a virtual disk on a VM ask disk space was running out. Having done this a million times before, I didn't expect anything to go wrong. However, as Murphy's law dictates, something had to go wrong. Here are the symptoms:

  • Cannot change the virtual disk size because the field is grayed out
  • Virtual disk is in IDE format

Unfortunately, you cannot expand an IDE virtual disk. In order to expand the disk, it must be first converted to a SCSI disk first. The procedures on how to do so are written below.

First off, prior to making any changes, make a backup (clone) or ensure that you already have a backup of the server. The last thing you want to have is production data being affected when you are doing a simple disk expansion.

Once that is done, power off the VM. Next, we want to add the SCSI controller and then boot into Windows to install the drivers. To add a SCSI controller, edit the virtual hardware of the VM and add a new hard disk (any size, thin format, store with virtual machine). Under the "Virtual Device Node" setting, select any SCSI device other than SCSI (0:0), ie: select SCSI (0:1).


Once that virtual disk has been created, the SCSI controller will be automatically added. You can verify this by looking at the virtual machine hardware. Once verified, start up the VM and boot into Windows where the SCSI controller should be automatically detected and installed (only if VMware Tools are installed). When you can see the second disk in disk management, shutdown the VM.



Next enable SSH into an ESXi host that is connected to the datastore where the IDE virtual disk resides. You will need to edit the VMDK file using a tool like WinSCP.



Connect via WinSCP and navigate to /vmfs/volumes/<datastore>/<vm> and open the .vmdk file associated with the IDE virtual disk. Change ddb.adapterType = "ide" to ddb.adapterType = "lsilogic". Save the file and exit WinSCP.




Edit the virtual machine hardware to remove the IDE disk. MAKE SURE YOU SELECT REMOVE FROM VIRTUAL MACHINE (FIRST OPTION). Selecting the wrong option will cause you to lose data.



Lastly, we need to add the disk again. Add a new disk, but this time, select "Use an existing virtual disk" instead of the other options. Navigate to where the IDE .vmdk file is stored and select SCSI (0:0) as the "Virtual Device Node".

The disk has now been converted to a SCSI virtual disk and it will now allow you to grow the disk as needed.