Unable to Power On Virtual Machine Because of Missing VMDK Header File

  1. Restoring from the last/latest backup.
  2. But if last backup was a week back and do not want to restore the delta then following steps needs to be followed to recover the VMDK file:
    1. Considering testvm as the virtual machine for this example.
    2. testvm.vmdk will be the name of the descriptive file.
    3. testvm-flat.vmdk will be falt file.
    4. Recreate testvm.vmdk which has been corrupted (header file missing).
      To create descriptive file:
      Login to ESX console as root using ssh client (putty or any ssh client). 2. Execute the command from the service console:
      [root@esx1]#cd /vmfs/volumes/volumes/dir
      Here volumes = volume name where the VM folder exists. dir = where ther Virtual Machine folder exists with all the VM files(Like .vmdk,-flat.vmdk,.vsm..etc).
  3. Execute the following command to record the size of the flat file.
    For example:
      [root@esx1-testvm]#ls -l testvm-flat.vmdk –rw——- 1 root root 65343764924 Mar 19 12:10 testvm-flat.vmdk
    OBS:Make a note of the exact size of the vmdk file.
    Here the size of the vmdk file is “65343764924“.
  4. Execute the command vmkfstools to create the new virtual disk of the same size of the existing vmdk file (testvm-flat.vmdk).
    For example:
      [root@esx1-testvm]#vmkfstool -c 65343764924 -a lsilogic new.vmdk
  5. The above command will create two files created within the VM (testvm) folder called new-flat.vmdk and new.vmdk.
  6. Remove the new-flat.vmdk file from the VM folder.
    [root@esx1-testvm]#rm new-flat.vmdk
  7. Rename the new.vmdk to the vmdk(corrupted) file to testvm.vmdk.
    Example:
      [root@esx1-testvm]#mv new.vmdk testvm.vmdk
    OBS: Before renaming please make a backup of the existing vmdk file.
  8. Now edit the descriptor file (testvm.vmdk).
    For example:
    [root@esx1-testvm]#vi testvm.vmdk
  9. Find the line with RW ####### and change the name of the -flat to match the orphaned -flat file.
    Here in the example, the new.vmdk was changed to testvm.vmdk as shown below:
    #Disk DescriptorFile version=3 encoding=”UTF-8″  CID=58d6fc82 parentCID=ffffffff createType=”vmfs”  #Extent description RW 167893630 VMFS “testvm-flat.vmdk” #vmdk file changed to testvm-flat.vmdk    #Change Tracking file  changeTrackPath=”testvm-ctk.vmdk”  
  10. Power On the Virtual machine to access the disk drive.
  11. If the virtual does not power On, try to re-register the virtual machine.
    To re-register the virtual machine, please follow the steps as mentioned below: Using CLI, unregister the virtual machine from vCenter.
    From the ESX console, execute the following commands as shown below:
    Unregister the VM (Equivavalent to removing the VM from the VC inventory)
    [root@esx1-testvm]#vmware-cmd –s unregister .vmx
    [root@esx1-testvm]#vmware-cmd –s unregister testvm.vmx
    Here in the example:
    Re-register the virtual machine to vCenter,by executing:
      [root@esx1-testvm]#vmware-cmd –s register .vmx
    (Equivavalent to adding VM back to VC inventory)
    Here in the example:
    [root@esx1-testvm]#vmware-cmd –s register testvm.vmx
To remove a virtual machine from VirtualCenter but not the datastore:
  1. From the VI Client, click the “Inventory” button in the navigation bar.
  2. Expand the inventory as needed, and click the appropriate virtual machine.
  3. Make sure that the virtual machine is powered Off.
  4. Select the virtual machine in the inventory panel.
  5. Choose “Inventory“, “Virtual Machine“, “Remove“, or right-click on the virtual machine and select “Remove from Inventory“.
  6. To remove the virtual machine from the inventory, click “OK“.
OBS:The Remove from Inventory command removes the virtual machine only from VirtualCenter inventory. It does not remove the virtual machine from its datastore.
To add the virtual machine in VirtualCenter Inventory:
  1. Connect to the ESX host/Virtual center using VI client.
  2. If connecting to VirtualCente, click on the desired host.
  3. Click the “Configuration” tab.
  4. Click “Storage“.
  5. Right-click on the appropriate datastore and click “Browse Datastore“.
  6. Navigate to the folder named after the virtual machine, and locate the .vmx file.
  7. Right-click the .vmx file and click “Add to inventory“.
  8. The Add to Inventory wizard will open. Continue to follow the wizard to add the virtual machine.
  9. Power On the virtual machine.

Leave a Reply