A. Mikkelsen VMware ESX scripts, commands, tools and other nice to know things that will make your virtualization days easier!!!!

Thursday, October 29, 2009

Extend disk with snapshots – How to fix the error

Filed under: Errors,ESXi,Troubleshooting,vSphere (ESX),White Papers — Tags: , , , , — A. Mikkelsen @ 8:55 am

Yesterday I by mistake extended a disk on a VM that had snapshots.
Using vmkfstools.
Kind of like this thread (http://communities.vmware.com/thread/238035).

This resulted in the following PowerOn error:

Failed to power on Servername on Host in Cluster:

Cannot open the disk ‘/vmfs/volumes/LUN/Folder/VM.vmdk’
Reason: The parent virtual machine disk has been modified since the child was created

The server was a database server so I had no choice than to fix it.

I tried the following with no luck:

  • Reverting to snapshot didn’t help – (Don’t try this if you don’t have a good backup)
  • Shrinking the vmdk again using vmkfstools – (This has not been possible since ESX 3.0)

Then I tried to use VMware Converter to do a V2V and in the first try (all defaults) that didn’t help the VM started with a BSOD.I tried again using the Converter but this time I changed one default parameter.In the “View/Edit Options” tap, remove the check mark in “Reconfigure destination virtual machine” and click YES to the warning.Removing the reconfigure option saved my day.
The VM started and I was able to restore the latest files from backup.


Monday, October 5, 2009

Powershell – Add host to Cluster and license it.

Filed under: PowerShell — Tags: , , , , , — A. Mikkelsen @ 19:40 pm

This PowerShell script adds a host to a Cluster and licenses it.


Add-PSSnapin VMware.VimAutomation.Core
Connect-VIServer "VC_server_name" -User "Administrator" -Password "password"
add-vmhost "esxhost" -location (get-datacenter -name 'Datacenter' | 
   get-folder -name 'Folder' | get-cluster -name 'Cluster') -user "root" 
   -password "password" -force: $true
$targethostMoRef = (get-VMHost $strHost  | get-view).MoRef
$si = Get-View ServiceInstance
$LicManRef=$si.Content.LicenseManager
$LicManView=Get-View $LicManRef
$licassman = Get-View $LicManView.LicenseAssignmentManager
$licassman.UpdateAssignedLicense($targethostMoRef.value,”YOUR LIC KEY”,
   ”vSphere4 Enterprise Plus (1-12 cores per CPU”)
Disconnect-VIServer -Confirm:$false

Download it here.

Powered by WordPress