File Cure upon being done with the scanning of the hard drive, displays an easy to read results chart. This utility easily identifies such things as corrupted.vmx files, common extensions which are not supported. Fix/Find Software Screen. File Cure easily as well as quickly fix corrupted.vmx file associated issues. Splitting the vdisk into multiple files isn't uncommon. You mentioned it hung when restoring, that sounds like the vm was hibernated instead of a full power off. So the ram will be stored in a file,.vmem I think. Maybe that got corrupted. I'd try deleting or renaming the Vmem file. Also make sure the host's disk isn't full.
Hi All,
I am writing this article because I just recently spent a few hours figuring out how to recover a Server Farm for a development lab I have been working on in Hyper-V.
![File File](https://techhead.co/wp-content/uploads/2009/01/image18.png)
The Scenario
You have a virtual machine(s) that you have been working on, however for some reason when you start Hyper-V and you connect to your virtual machine, you receive an error such as: 'Cannot connect to virtual machine because of x'. You check your logs and you discover that something is corrupt. In my case, my snapshot files had become corrupted. This can happen for a plethora of reasons, but the case is that it has happened.
So what do you do?
First, turn off your Hyper-V Service and then turn it back on and try connecting again, it could be that you attached a new drive and was not picked up on service start up.
If you clicked delete on the VM already and received the 'Catastrophic error' and now your VM is just hanging out, that's OK, we will address that. If you haven't done that, that's ok too.
1. Remove the Virtual Machine and all remnants of it from Hyper-V.
1a. Stop The Hyper-V Service from the Hyper-V Console on the server hosting your machine.
1b. Navigate to: C:ProgramDataMicrosoftWindowsHyper-V
I. You will need to select show hidden folders and give yourself administrator permissions over that folder.
1c. Delete only the files associated with the virtual machine.
I. Navigate to Virtual Machines and open each one until you find the one with tag <name type='string'>YOUR NAME</name> should be near the bottom
ia. The file name of this .xml is that machine's GUID.
ii. Delete That machine and its associated (same file name) in the folder Locks.
iii. Repeat this for the directory Virtual Machines Cache
iv. Navigate to Snapshots
iva. Open each file and search for the GUID of your virtual machine.
ivb. Note the name of each of the .xml files which you find the GUID of your virtual machine in.
ivc. Delete all of those .xml files
ivd. Delete the maching file names in the folder Locks within that same Snapshots directory
v. Repeate iv except with Snapshots Cache.
1d. Start the Hyper-V Service on your server again.
2. Restore Your Virtual Machine
This can go different ways depending on your scenario.
1. Virtual Machine Configuration was corrupted.
1a. Delete your virtual machine .xml file.
1b. Create a new virtual machine and point to the latest .avhdx file in accordance to the snapshot you wish to utilize from your machine.
1c. Point your snapshots directory to the current snapshots directory.
2. Snapshots Configuration was corrupted
2a. Delete Snapshots .xml files
2b. Import your virtual machine as a restore pointing the hard drive to the .avhdx file in accordance to the snapshot you wish to utilize.
2c. Point snapshots to the folder you wish to use.
3. You had a back up copy prior to corruption
3a. Delete old Directory and copy back up to this location.
3b. Import Virtual Machine and do it in place pointing to your newly copied over back up.
There are probably some other scenarios to consider, but those are some of the primary ones I have run into.
Hope that helps!
~Dave
Do you have a VM that is missing its VMX file or maybe the VM’s VMX file has corrupted?
Now you could manually recreate a missing or corrupt VMX file (restoring one from a backup would be the best solution) but a quick and easy way for recreating it is to create a new VM within the VMware Infrastructure Client (VIC) or via CLI/RCLI. During the creation process point the new VM’s drives to the existing disk (VMDK) files of the server with the corrupt/missing VMX file.
Below are the basic steps for doing this via the VMware Infrastructure Client interface.
Before beginning to start the process to recreate the VMX file, if it exists, remove the VM from the VMware Infrastructure Clients inventory list (right click on the VM and select ‘Remove from Inventory’). Also if you are trying to replace a corrupted VMX file then rename (preferable option) or delete the offending VMX file.
First start the ‘New Virtual Machine Wizard’ and select a ‘Virtual Machine Configuration’ type of ‘Custom’.
The next page of the wizard will ask for a ‘Name’ for the new VM. Make sure the name you type in here matches the name of the directory on your VMFS partition that hosts the VM with the missing/corrupt VMX file.
If you enter in a different name here the New Virtual Machine Wizard will create a directory of that name that will contain the VMX file (along with a couple of other files important to the running of the VM) whilst your disk (VMDK) file(s) could be located in another directory. Although there are potentially situations where you may want to keep your disk and configuration files separate I would personally recommend keeping them all together to reduce the risk of any future confusion and accidental moves or deletions of these VM related files.
![Corrupt Corrupt](https://i.stack.imgur.com/41Epl.jpg)
The next screen of the Wizard asks for you to select the location of the datastore. As mentioned above, in most situations it is best to select the same LUN/Disk on which the VMDK (disk) files are located.
Now proceed through the next few steps of the Wizard selecting and adjusting (if required) any of the VM configuration parameters (eg: Guest OS, number of virtual processors, memory, etc).
When you get to the ‘Select a Disk’ screen then select ‘Use an existing virtual virtual disk’ and select the primary VMDK boot disk file for the VM with the missing/corrupt VMX file.
Proceed through the rest of the Wizard until you get to the ‘Ready to ‘Complete New Virtual Machine’ screen. At this point if you wish to add any additional secondary (eg: data) disks then check the ‘Edit the virtual machine settings before submitting’ box and add in any additional disks, NICs, etc.
Once complete then press the ‘Finish’ button. Within the VMware Infrastructure Client interface you will now see the newly recreated VM back in the inventory list.
Using the ‘Datastore Browser’ navigate to the folder of VM and you should now see a freshly created VMX file.
You are now ready to start the VM with its new VMX file. Good Luck!