I am using PowerCLI 5.5 on vSphere 5.0.
I am trying to deploy VMDKs which were created with a switch in Symantec Ghost that defaults the hard disk to IDE. How can I change the HD from IDE to SCSI using PowerCLI?
We are also looking at regenerating the VMDKs with the correct setting in Ghost, but that may not be feasible.
I looked at the post below, which seems close, but doesn't tell me how to change the Type only the Disk ID number.
Any way to set Virtual Device Node / SCSI Disk ID?
When I look at the vmdk on the host for the VM, I can see that the ddb.adapterType field is set to "ide" and per KB 1016192 - Converting a virtual IDE disk to a virtual SCSI disk
I need it to be set to "lsilogic", but I can't manually edit the vmdk file.
Also, the Hard drive has the VM operating system already installed on it, so I don't want to just delete it.
Another related problem is that I can't set the SCSi Controller type from LSI Logic SAS to LSI Logic Parallel (the windows VMs won't start if it's set to LSI Logic SAS). I just get an "Incompatible backing specified for device 0" error.
Appreciate any ideas.
I figured I would come back and update this post. I got this to work by changing a setting when I create the VMDKs.
I changed the way I created the VMDK via the Symantec ghost32.exe application (version 11.5.?) by adding the following switch:
-vmdkAdapter=lsilogic
ghost32 -clone,mode=restore,src="%SRC%",dst="%DEST%" -vmdkAdapter=lsilogic -sure
This worked for my Windows 2008 VMDKs, not sure what it will do for any other type.
In the end, I was never able to change the VMX file from PowerCLI, although I did get pretty close.
With regards to PowerCLI, I think I corrupted the files on the ESXi server and could never get around it. The steps were roughly as follows
1. Use Copy-DatastoreItem cmdlet to copy vm.vmx file to local computer desktop
2. Use Get-Content to read file and replace ddb.adapterType="ide" with ddb.adapterType.="lsilogic"
3. Copy a ConvertTo-LinuxLineEnding cmdlet from internet and remove CR/LF chars at the BYTE level; because nothing else worked. I still don't think this worked 100%.
4. Copy-DatastoreItem to copy the vmx file back to the VM directory.
The vmx file has the correct setting and appears ok, but I think something is broken here, because when I use VI Client to look at the datastore, there are only 2 files in the directory. I can't remember which ones any more.
5. Remove-HardDrive
6. New-HardDrive -vm $vmObj -diskpath "[datastoreName] vm/vm.vmdk", at this point I get "the specified Disk path is inaccessible or does not exist". This is most likely because I have corrupted the file structure on the datastore.
When I delete the VM in the VI Client, I can delete it successfully, but I have to also manually delete the directory on the datastore using the Browse
Datastore command.
Maureen
Did you already try like this
Get-VM MyVM | Get-HardDisk | New-ScsiController -Type VirtualLsiLogic
And also take note of Re: Set-ScsiController -Type VirtualLsiLogicSAS
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Why can't you change the VMDK file, don't you have permissions or do you get certain errors ?
Because if you can change the VMDK file and re-add the disk, the correct SCSI controller will be chosen.
This is how I did it before :
1) Turn off the VM
2) Locate the ESX host from the VM
3) Locate the datastores of the disks to edit
4) Turn on SSH on the ESX
5) Connect using SSH and go to the VM folder
1 | # cd /vmfs/volumes/<datastore_name>/<vm_name>/ |
Now open the VMDK file using a VI editor like VI or nano for more information about VI/Nano
Editing files on an ESX host using vi or nano (1020302)
*Note: Nano is not available in ESXi. But can manually be installed
6) In this case we edit the TEST_PAT.vmdk file
1 | # vi TEST_PAT.vmdk |
When you look at the file you will see a ddb.adaptertype = “IDE” this is the value ESX uses to determine the adapter to use.In this case, when you add the VMDK using “add new disk -> use existing disk” it will see IDE and add an IDE adapter.
So wee need to change this value
Specify one of these parameters: lsilogic or buslogic .
This table shows the adapter type for the guest operating system:
Guest Operating System | Adapter Type |
Windows 2003, 2008, Vista | lsilogic |
Windows NT, 2000, XP | buslogic |
Linux | lsilogic |
In this case we chose the lsilogic
Change IDE to LSILOGIC and save the file.
Next go back to your virtual machine and remove the disks you edited (don’t remove it from your storage), so wisely chose “Remove from Virtual Machine”
It’s important not to remove the disk first before you start editing because the VMDK descriptor file doesn’t exist yet if the disk is not connected to a VM.
Apply the settings. Now go back to edit settings -> add -> Harddisk -> Use an existing virtual disk -> Browse to the location of the disk file and click next a few times.
As you notice it will display Disk adapter as SCSI now.
Now you added your SCSI disk.
WH33ly, when I said I couldn't edit the vmdk file, I didn't mean that I couldn't get to the VMDK file to edit it, I meant that I want to script this process. I am trying script the deployment of a lot of VMs and I want to keep people's hands out of the loop as much as I can.
Luc, I haven't gotten far enough to set the SCSI Adapter.
This is what I have going so far and it's pretty close, but not behaving consistently:
1. Create a VM with some basic attributes, some CPUs, a datastore, some NICs, some memory, etc. This is basically a shell.
2. Use the Copy-Harddisk cmdlet to copy a VMDK into the VM shell - this is where my IDE setting comes from, which I need to fix in the original VMDK.
3. Copy the vmName.vmkd file from the datastore to my local laptop and change the "ide" setting to "lsilogic"
MY SCRIPT works great up to this point.
4. Copy the vmdk file from my laptop, BACK to the original datastore location for the VM.
5. Delete Harddisk (from VM only) and add it back, where it will now have proper setting
I've been getting mixed unsucessful results, so I can't pinpoint exactly what is going wrong, but I'm still looking into it.
Sometimes I get Service Unavailable 503 errors copying the file back to the datastore, not exactly sure why, but it happens often enough to feel like some kind of race condition.
When I get the 503 error, I have to start over or else add some kind of loop to keep trying, yuck.
When the VMDK copy works, the delete/readd of the Harddisk doesn't work (specifically, readding the disk)
Also,
I've tried pausing the script after copying the new VMDK and manually deleting/readding the Hard Disk from the VI Client.
But VI Client doesn't seem to "see" the new vmdk file, when I browse to the datastore to add the Hard disk back, I don't get the VMDK as an option
If I SSH into the ESXi server, I can see the new VMDK file with the correct setting.
It feels like I broke some connection in the VMDK files when I overwrote the existing one.
The problem where vSphere is not recognizing my newly copied VMDK file seems to be related to Windows adding "^M" chars into my vmdk file when I was updating the version on my laptop. A Windows carriage return/Line feed is interpreted as a "^M" sequence on Linux.
Also, the ^M only showed up when I used vi to look at the file, the more command showed it as fine.
I will have to figure out how to update the file without any of the Windows clutter and I will try it again.
I figured I would come back and update this post. I got this to work by changing a setting when I create the VMDKs.
I changed the way I created the VMDK via the Symantec ghost32.exe application (version 11.5.?) by adding the following switch:
-vmdkAdapter=lsilogic
ghost32 -clone,mode=restore,src="%SRC%",dst="%DEST%" -vmdkAdapter=lsilogic -sure
This worked for my Windows 2008 VMDKs, not sure what it will do for any other type.
In the end, I was never able to change the VMX file from PowerCLI, although I did get pretty close.
With regards to PowerCLI, I think I corrupted the files on the ESXi server and could never get around it. The steps were roughly as follows
1. Use Copy-DatastoreItem cmdlet to copy vm.vmx file to local computer desktop
2. Use Get-Content to read file and replace ddb.adapterType="ide" with ddb.adapterType.="lsilogic"
3. Copy a ConvertTo-LinuxLineEnding cmdlet from internet and remove CR/LF chars at the BYTE level; because nothing else worked. I still don't think this worked 100%.
4. Copy-DatastoreItem to copy the vmx file back to the VM directory.
The vmx file has the correct setting and appears ok, but I think something is broken here, because when I use VI Client to look at the datastore, there are only 2 files in the directory. I can't remember which ones any more.
5. Remove-HardDrive
6. New-HardDrive -vm $vmObj -diskpath "[datastoreName] vm/vm.vmdk", at this point I get "the specified Disk path is inaccessible or does not exist". This is most likely because I have corrupted the file structure on the datastore.
When I delete the VM in the VI Client, I can delete it successfully, but I have to also manually delete the directory on the datastore using the Browse
Datastore command.
Maureen