Friday, 5 December 2014

VMware ESX – How to easily recreate a missing or corrupt VMX file.


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’. 
image
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.
image 
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.
image
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. 
image
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.
image
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.
vmxfile
You are now ready to start the VM with its new VMX file.  Good Luck!

No comments:

Post a Comment