Thursday 23 July 2015

Deploying multiple VMs fails with error "Error caused by file /vmfs/volumes/datastore_id/path_to/source.vmdk" on ESXi 5.5 u2

I've been puzzled over this issue for quite a long time.

Customer has some cloud solution on top of vSphere 5.5 u2 and deploying/cloning multiple VMs from template/VM fails with an error:

"Error caused by file /vmfs/volumes/datastore_id/path_to/source.vmdk".

This errors shown in vSphere client during "Apply Storage DRS recommendation".

I was able to replicate this behaviour with simple PowerCli script:

$vmquantity = 5
$template = Get-vm -Name "template_vm"
$dsclu = Get-DatastoreCluster -Name DS_clu1_foo
$clu = Get-Cluster -Name Clu1_foo
$vmlocation = Get-Folder -Name Folder_foo


1..$vmquantity |ForEach-Object {
$vmname = "testVM$_"
New-VM -ResourcePool $clu -Name $vmname -Datastore $dsclu -Location $vmlocation -VM $template -RunAsync 
}

Key here is "RunAsync" parameter, only then problem occur.

I did a lot of unnecessary steps, like disabling VAAI, changing datastore and storage controller queues, without success.

Simple solution resolved this issue: deleting ctk.vmdk file of source VM/template fixed the problem. Also, make sure that .vmx or .vmtx files doesn't have any reference to deleted files.

There is some VMware KB with this solution but it is not related to the error I was getting.VMware should update their KB's because solution was hard to find.

Update:

I noticed that backups also are affected by this (at least TSM backup can be), that is snapshots are not created and as a result backup fails. Deleting ctk file can help here also.

Tuesday 7 July 2015

Powershell ISE usefull keyboard shortcuts

Here they are, why I forget them all the time is beyond me.

Ctrl + T - opens new PowerShell session in new tab.

Ctrl + Space - runs intellisense against typed text

Ctrl + J - allows to insert predefined code to your script

Ctrl + R - shows/hides script pane (maximizes console view)

Ctrl + I - goes t othe script pane

Ctrl  +D - goes to console pane

Ctrl + G - Go to line

F8 - executes one line on cursor position

F5 - executes whole script