Recreating encrypted or damaged .vmdk file

  • Computer name used: windows
  • Encrypted file name: windows.vmdk
  • Datastore name: SSD
  • Recovery VM Name Folder: restore
  1. Connect to ESXi host as root through SSH.
  2. Navigate to:
    • cd /vmfs/volumes/SSD/restore
    • ls -lah
      • total 10968192
      • drwxr-xr-x 1 root root 72.0K Jun 3 20:45 .
      • drwxr-xr-t 1 root root 72.0K Jun 3 20:44 ..
      • -rw——- 1 root root 176.7K Jun 3 20:44 vmware.log
      • -rw——- 1 root root 48.0G Jun 3 20:44 windows-flat.vmdk (.vmdk file missing)
      • -rw——- 1 root root 264.5K Jun 3 20:44 windows.nvram
      • -rw——- 1 root root 0 Jun 3 20:44 windows.vmsd
      • -rw——- 1 root root 3.2K Jun 3 20:44 windows.vmx
  3. Identify the SCSI controller
    • less *.vmx | grep -i virtualdev
      • pciBridge4.virtualDev = “pcieRootPort”
      • pciBridge5.virtualDev = “pcieRootPort”
      • pciBridge6.virtualDev = “pcieRootPort”
      • pciBridge7.virtualDev = “pcieRootPort”
      • scsi0.virtualDev = “lsisas1068”
      • ethernet0.virtualDev = “e1000e”
  4. Get the exact size of the flat .vmdk file:
    • ls -l windows-flat.vmdk
      • -rw——- 1 root root 51539607552 Jun 3 20:44 windows-flat.vmdk. (files size: 51539607552)
  5. Using vmkfstools create a new temp virtual disk:
    • vmkfstools -c 51539607552 -a lsisas1068 -d thin temp.vmdk
      • Create: 100% done.
  6. List files:
    • drwxr-xr-x 1 root root 72.0K Jun 3 21:12 .
    • drwxr-xr-t 1 root root 72.0K Jun 3 20:44 ..
    • -rw——- 1 root root 48.0G Jun 3 21:12 temp-flat.vmdk (new file)
    • -rw——- 1 root root 471 Jun 3 21:12 temp.vmdk (new file)
    • -rw——- 1 root root 176.7K Jun 3 20:44 vmware.log
    • -rw——- 1 root root 48.0G Jun 3 20:44 windows-flat.vmdk
    • -rw——- 1 root root 264.5K Jun 3 20:44 windows.nvram
    • -rw——- 1 root root 0 Jun 3 20:44 windows.vmsd
    • -rw——- 1 root root 3.2K Jun 3 20:44 windows.vmx
  7. Rename the temporary vmdk file to match the the missing vmdk file
    • mv -i temp.vmdk windows.vmdk
      • drwxr-xr-x 1 root root 72.0K Jun 3 21:18 .
      • drwxr-xr-t 1 root root 72.0K Jun 3 20:44 ..
      • -rw——- 1 root root 48.0G Jun 3 21:12 temp-flat.vmdk
      • -rw——- 1 root root 176.7K Jun 3 20:44 vmware.log
      • -rw——- 1 root root 48.0G Jun 3 20:44 windows-flat.vmdk
      • -rw——- 1 root root 264.5K Jun 3 20:44 windows.nvram
      • -rw——- 1 root root 471 Jun 3 21:12 windows.vmdk
      • -rw——- 1 root root 0 Jun 3 20:44 windows.vmsd
      • -rw——- 1 root root 3.2K Jun 3 20:44 windows.vmx
  8. Edit the .vmdk file to point to correct -flat.vmdk file
    • vi windows.vmdk
      • Disk DescriptorFile
      • version=1
      • encoding=”UTF-8″
      • CID=fffffffe
      • parentCID=ffffffff
      • createType=”vmfs”
      • Extent description
      • RW 100663296 VMFS “temp-flat.vmdk” ( change to RW 100663296 VMFS windows-flat.vmdk )
      • The Disk Data Base
      • DDB
      • ddb.adapterType = “lsilogic”
      • ddb.geometry.cylinders = “6266”
      • ddb.geometry.heads = “255”
      • ddb.geometry.sectors = “63”
      • ddb.longContentID = “abf1f7fe4f9532ba5ed7f015fffffffe”
      • ddb.thinProvisioned = “1” ( remove this line if the original disk is not thin provision )
      • ddb.uuid = “60 00 C2 91 16 a3 cd a7-fb b4 7b 9f 7b 55 b3 89”
      • ddb.virtualHWVersion = “14”
  9. Delete the temporary flat file:
    • rm -i temp-flat.vmdk
  10. Check the disk consistency:
    • vmkfstools -e windows.vmdk
      • Disk chain is consistent.

The machine is ready to be powered on.


Leave a Reply 0

Your email address will not be published. Required fields are marked *