Unfortunately there came a time where I had to repair a virtual machine and I quickly started running out of hope. But I found one thread which described my predicament and followed the following steps to get the VM back and running (phew!).
SureshKumarMuth explains the basics very well here:
From the KB article above I was successful in doing the following:
- Identify and record the exact size of the -flat file using this command:
ls -l vmdisk0-flat.vmdk
-rw------- 1 root root 4294967296 Oct 11 12:30 vmdisk0-flat.vmdk
- Use the vmkfstools command to create a new temp virtual disk:
# vmkfstools -c 4294967296 -d thin temp.vmdk
The command uses these flags:- -c size
This is the size of the virtual disk. - -d thin
This creates the disk in thin-provisioned format.
- -c size
The temp.vmdk and temp-flat.vmdk files are created as a result.
Note: To save disk space, we create the disk in thin-provisioned format using the type thin. The only consequence, however, is that the descriptor file contains an extra line that must be manually removed in a later step if the original disk is not Thin provisioned.
- Delete temp-flat.vmdk, as it is not needed. Run this command:
rm -i temp-flat.vmdk
- Rename temp.vmdk to the name that is required to match the orphaned -flat file (or vmdisk0.vmdk , in this example):
mv -i temp.vmdk vmdisk0.vmdk
- Edit the descriptor file using “vi” text editor ( vi vmdisk0.vmdk, in this example)
- Under the Extent Description section,
- Use command “Insert” to allow modifications on the descriptor file.
- Locate and change the name of the -flat file to match the orphaned -flat. Once completed – hit “Esc” to exit this mode.
- Find and remove the line
ddb.thinProvisioned = "1"
if the original .vmdk was not a thin disk. If it was, retain this line. Use command “:wq!
” to save and exit “vi” editor.
- Under the Extent Description section,
Hope this helps you out if you (unfortunately) find yourself in this situation.