Recreating missing virtual disk (VMDK) Descriptor File
Problem-
You just noticed that virtual machine’s VMDK files are missing and lost somehow. The reason, not able to start VM and when you try to add existing HDD – existing VMDK and -flat. VMDK files are not available to attach with Virtual Machine too.
Solution –
We need to recreate missing VMDK files, to add VMDK files and start Virtual Machine.
- Login to ESXI PS with Putty. Make sure, SSH service is enabled and running for the PS.
- Switch to the directory where your virtual machine is located.
cd /vmfs/volumes/<<datastore>>/VM-Directory
cd /vmfs/volumes/5d406ca3-62654bd0-75fd-e4434b75ed38/APP-U1-63-25
3. Run below command to identify and record the exact size of the existing flat vmdk file for the VM.
ls -ltr *
-rw——- 1 root root 16106127360 Jun 21 12:20 APP-U1-63-25-flat.vmdk
-rw——- 1 root root 214748364800 Jun 21 10:49 APP-U1-63-25_1-flat.vmdk
4. Run the vmkfstools to create new virtual disk, i.e VMDK (Descriptor File)
vmkfstools -c 16106127360 -d thin -a lsilogic APP-U1-63-25-OS.vmdk
vmkfstools -c 214748364800 -d thin -a lsilogic APP-U1-63-25-DATA.vmdk
5. As mentioned, there are 2 new files created: APP-U1-63-25-OS.vmdk and APP-U1-63-25-DATA.vmdk are created as a result.
ls -ltr
–rw——- 1 root root 16106127360 Jun 21 19:21 APP-U1-63-25-OS-flat.vmdk
-rw——- 1 root root 214748364800 Jun 21 19:21 APP-U1-63-25-DATA-flat.vmdk
-rw——- 1 root root 546 Jun 21 21:05 APP-U1-63-25-OS.vmdk
-rw——- 1 root root 550 Jun 21 21:05 APP-U1-63-25-DATA.vmdk
-rw——- 1 root root 214748364800 Jun 22 05:08 APP-U1-63-25_1-flat.vmdk
-rw——- 1 root root 16106127360 Jun 22 05:08 APP-U1-63-25-flat.vmdk
6. We need to Rename APP-U1-63-25-OS.vmdk and APP-U1-63-25-DATA.vmdk to the name that is needed to match the orphaned -flat file.
mv APP-U1-63-25-OS.vmdk APP-U1-63-25.vmdk
mv APP-U1-63-25-DATA.vmdk APP-U1-63-25_1.vmdk
7. Now, it is final stage where editing descriptor file (APP-U1-63-25.vmdk and APP-U1-63-25_1.vmdk)
find the line with RW ####### and change the name of the -flat to match the orphaned -flat file you have. So, I changed to APP-U1-63-25-flat.vmdk and APP-U1-63-25_1-flat.vmdk respectively for both disks, as you can see in the image below.
vi APP-U1-63-25.vmdk
vi APP-U1-63-25_1.vmdk
8. You can now delete the below files created earlier. These are not required anymore.
–rw——- 1 root root 16106127360 Jun 21 19:21 APP-U1-63-25-OS-flat.vmdk
-rw——- 1 root root 214748364800 Jun 21 19:21 APP-U1-63-25-DATA-flat.vmdk
9. Attach the respective VMDK files to the virtual machine as earlier.
10. Now, All set and good to power on the virtual machine.