vSphere convert VM IDE disk to SCSI disk
I recently read a post by Duncan Epping over at Yellow Bricks where he tried to resize the VMDK of a Windows XP VM running on ESX\vSphere. When he used the VI Client to try and resize the VMDK he was actually unable to because it was ghosted out. By coincidence I had experienced the same problem a week before Duncan after building 5 Windows XP VMs for stress testing of a new SharePoint website. As Duncan mentioned, the only other time I had seen this happen was when a snapshot existed for the disk that needed to be resized. Quickly checking the VM's settings I noticed that by default, when you create a Virtual Machine using the 'Microsoft Windows XP Professional..." Guest Operating System container it actually attaches an IDE disk rather than a SCSI disk (Server 2003 and 2008 Guest Operating System containers use a SCSI disk by default.)
Here are the default devices for the Windows XP Professional VM:
Since I had built the 5 Windows XP VMs from a template I had created, I decided to find a way to convert the IDE disk to a SCSI disk and update the template incase I needed to resize the OS disk in the future. The easiest way I found to do this was as follows:-
Firstly I made the following assumptions:
- I would need to add a SCSI Controller to the VM and install the drivers before booting from the VMDK (I have seen cases before where moving a HD to new hardware caused a BSOD)
- If possible I would need to change the default Controller used for new VMDKs from IDE to SCSI
- I wanted to use the LSI Logic SCSI Controller
- I wanted to make the VMDK the first SCSI device (0:0) attached to the Controller
So, with the VM powered OFF I edited the settings for it through the VI Client and added a new SCSI Device (by default it doesn't seem possible to simply add a SCSI Controller to a VM without also attaching a SCSI Device to it):
I left the SCSI Device as being a CDROM and (optionally) changed the Virtual Device Node to SCSI (0:1) so that when I converted the existing disk and added it to the SCSI Controller it would be device SCSI (0:0). I clicked Next and Finish but I didn't click OK to commit the changes:
Before clicking OK, I selected the SCSI Controller and changed it's type as appropriate. Then I clicked OK to commit the changes to the VM:
I powered on the VM and noticed that the Windows Found New Hardware Wizard prompted me to install the driver for the SCSI controller. I knew that the controller used is a LSI20320-R so I downloaded it from here:
LSI20320-R - Driver Download (Click the Support and Downloads tab)
I downloaded the appropriate driver and extracted it (for Windows XP 32bit I used LSI20320-R_xp_50700_01034132IT_1201800_1005239.zip and within that symmpi_wXP_1201800.zip.) Then I used the Found New Hardware Wizard to browse for and install the driver. Once the hardware installation completed I shut down the VM. The VM now had the SCSI controller installed and I was confident I would be able to boot from it.
I then located the datastore where the VM resides. For example:
You can use the Service Console or an SSH\SCP application to open the <vm>.vmdk (not the <vm>-flat.vmdk). I edited the following line:
ddb.adapterType = "ide"
For the LSI SCSI Controller I changed it to:
ddb.adapterType = "lsilogic"
After saving the file I used the VI Client to edit the VM settings. I selected the IDE disk and removed it. I then clicked OK to commit the changes.
NOTE: Remember to only 'Remove from virtual machine' and NOT 'Remove from virtual machine and delete files from disk':
Then I used the VI Client to edit the VM settings again and add the disk back. This time, because I had edited the .vmdk file to specify that the disk uses the LSI Logic Controller, it attaches the disk to this instead of the IDE Controller used previously:
The disk is added as device SCSI (0:0):
I clicked Next and Finish to complete adding the disk. I then selected the CDROM (SCSI device 1) and removed it:
I clicked OK to commit the changes to the VM. I now had a VM using the LSI Logic SCSI Controller with the System OS disk connected to the Controller as device SCSI (0:0).
Since the VM had already booted with the LSI Logic Controller installed, when I powered on the VM Windows booted normally and was immediately accessible. Subsequently, any new virtual disks created for the VM are automatically created as SCSI disks and attached using the next available Virtual Device Node.