Recover lost or corrupt vmdk virtual disk descriptor

After losing some VmWare ESXi vmdk configuration files, I had to recover them somehow. Especially the ".vmdk" description files were corrupt. Actually I didn't even know the name or the disk size of the virtual hdd-s.

The way I recovered them was according to this site:

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1002511

Desktop VmWare products also have this feature (http://www.vmware.com/pdf/VirtualDiskManager.pdf), but I wanted to try it with ESXi.

Some VmWare conventions:

  • host: the VmWare player/server/workstation
  • guest: virtual machines installed into the host
  • desktop machine: my laptop where the VmWare host is installed

The following is the procedure:

  1. Download the FREE VmWare player and VmWare ESXi installers
  2. Install an ESXi server into my VmWare player.
  3. Enable the SSH maintenance port on the ESXi.
  4. Install the vSphere client to the desktop machine to be able to configure the ESXi guests.
  5. Copy the virtual disk vmdk-s to the ESXi datastore
  6. Login to the ESXi via SSH, go to the copied files with
    cd /vmfs/volumes/datastore1/work
  7. Determine the size of the disks:
    ls -l
  8. Execute the following command with custom parameters:
    vmkfstools -c 4294967296 -a lsilogic -d thin temp.vmdk
    where the long number is the size of the virtual disk determined with "ls -l". The "lsilogic" can be determined from the ".vmx" file, which I did not have, so I guessed. The command generates "temp.vmdk"
  9. Download the "temp.vmdk" to desktop
  10. Edit it with Notepad++ and delete the following line: "ddb.thinProvisioned = 1". The virtual disk file name can be set in the file after "# Extent description" like "RW 8388608 VMFS "vmdisk0-flat.vmdk"""
  11. Delete files from the datastore.
  12. Create a virtual machine in VmWare player with custom settings and when it asks for creating a new virtual disk, select to "use an existing virtual disk" option and choose your new "temp.vmdk". Of course you can rename it.
  13. Play the machine.