Tuesday, March 1, 2011

Recreate missing vmdk files

Today a colleague of mine (or me) did a mistake browsing the datastores using the vSphere-Client.
He found a folder with a machine (srv01) that he believed was discontinued, he market the "srv01" folder and pressed delete...
After a while the vSphere-Client showed an error message saying that some files were in use.
What happened was that the vmdk files were deleted (description-files) but the srv01-flat.vmdk (the actual datadisks) files were not deleted due to the fact that the VM was running.
The server was still running but for some reason my colleague decided to reboot the server... Bad idea.
The server complain about missing files and would not start.

Below solved the issue for me.
To recreate the description files i did as follow.
Enable RemoteTechSupport on the ESX that host the VM.
Login to the ESX using putty.
Browse to the datastore where the srv01-flat.vmdk reside.
To get the size of the vmdk do an "ls-l srv01.vmdk "
Note the size of the vmdk.
Use vmkfstools : " vmkfstools -c 4874254770 -d thin -a lsilogic new.vmdk"
Remove the "flat-new.vmdk"
Rename the new.vmdk to the same name as the missing vmdk. (srv01.vmdk)
Use Veeam to browse the datastore and rightclick and edit the srv01.vmdk file.
Change the name on the line RW 132432543  "new-flat.vmdk" to  srv01-flat.vmdk
Now you should be able to boot your VM again.

Source VMware KB 1002511