How to recreate a missing VMware virtual machine disk descriptor file (.vmdk)

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:

Basically, each virtual disk will have two files

1. Descriptor file

2. Data file

for a disk without snapshot , you will have the file in this naming convention (taken your server name as example)

Webserver0.vmdk — is the descriptor file of base disk

Webserver0-flat.vmdk — actual data file ( if we delete this then we cannot recover data if we do not have any proper back up or using proper recovery tool)

In case if you have snapshot , you will find many disks in the following naming convention depends on the number of snapshots you have . in your case if appears that you have 6 snapshots

Webserver0-000001.vmdk — descriptor file, can be recovered using the delta disk.

Webserver0-000001-delta.vmdk (data disk)

In your case, fortunately you deleted only the descriptor file which can be recovered using the steps given in the following video and kb article

How to recreate a missing Virtual Machine Disk Descriptor File (VMDK) – YouTube

VMware Knowledge Base

Waiting for the output from ESXi ssh session for further steps

From the KB article above I was successful in doing the following:

  1. 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
  2. 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.

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.

  1. Delete temp-flat.vmdk, as it is not needed. Run this command:

    rm -i temp-flat.vmdk
  2. 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
  3. Edit the descriptor file using “vi” text editor ( vi vmdisk0.vmdk, in this example)
    1. 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.
    2. 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.

Hope this helps you out if you (unfortunately) find yourself in this situation.

About the Author

You may also like these