This week, I've done an upgrade vSphere from 5.0 to 5.5 U2 with latest patch. After upgrading one of ESXi host and rebooting it, I realized that one VM's .vmx, .vmdk files dissapeared and VM was shown as "inacessible" in the vCenter inventory. Fortunately after investigating datastore, we could find "VM-flat.vmdk" file. It has not been my first time to see such problem (e.g. few times I have come up against this problem after restoring VM from backup) so I decided to describe how to solve it.
To recreate .vmx file, bios etc, the easiest way is to create a new VM with the same hardware settings as the original one (of course, if you remember it...). So just "New Virtual Machine --> Typical" and so on.
To recover a .vmdk descriptor file you should follow below steps:
- Identify the size of the flat file in bytes. Create a new blank virtual disk that is the same size as the original. This serves as a baseline example that is modified in later steps.
As on above screenshot, use the vmkfstools command to create a new virtual disk: vmkfstool -c size -a lsilogic -d thin name where:
- -c size - This is the size of virtual disk
- -a virtual_controller (BusLogic, LSILogic,Paravirtual, or IDE)
- -d thin - This creates the disk in thin-provisioned format (also zeroedthick , eagerzeroedthick options available)
- Rename the descriptor file (also referred to as a header file) of the newly-created disk to match the name of the original virtual disk.
- Modify (using vi) the contents of the renamed descriptor file to reference the flat file.