How to recover missed VMDK descriptor file
VMware’s VMDK files have two formats, ESX, and local formats, which are identified by a text description in the binary file or a separate text file (descriptor file).
A VMDK descriptor file is a crucial file; it stores the virtual disk information, such as the disk’s geometry, IDs, and virtual hardware version. The descriptor file is available as a TXT file, and as such, you can easily view it using any text editor application.
However, it is crucial that nothing happens to the descriptor file because this is where the real VM data is stored. However, if the VMDK descriptor files for your VHD disappear for whatever reason, this article offers detailed instructions on how to quickly retrieve the file.
How to build a disk descriptor file for a virtual machine
- 1. Through SSH or DCUI, establish a root connection to the ESXi host.
- 2. Use the command: to go to the directory that houses the virtual machine disk with the missing descriptor file.
cd /vmfs/volumes/DATASTORE_NAME/VM_NAME
- 3. Examine the virtual machine configuration file to see what kind of SCSI controller the virtual disk is employing (.vmx ). The controller is identified by the line scsi#.virtualDev , where # is the controller number.
Use lsilogic:
scsi0.present = "true"
scsi0.sharedBus = "none"
scsi1.present = "true"
scsi1.sharedBus = "virtual"
scsi1.virtualDev = "lsilogic"
- 4. Use the following command to determine and note the precise size of the -flat file:
ls -l vmdisk0-flat.vmdk
-rw------- 1 root root 4294967296 Oct 11 12:30 vmdisk0-flat.vmdk
- 5. To build a fresh temporary virtual disk, use the vmkfstools command:
# vmkfstools -c 4294967296 -d thin temp.vmdk , where -c size is the size of the virtual disk, and -d thin is disk in thin-provisioned format.
- 6. There is no need for temp-flat.vmdk, therefore remove it. Execute this command:
rm -i temp-flat.vmdk
- 7. Rename temp.vmdk to the name necessary to correspond with the orphaned -flat file (in this case, vmdisk0.vmdk) as follows:
mv -i temp.vmdk vmdisk0.vmdk
- 8. Using the "vi" text editor, modify the descriptor file
Under the Extent Description section - to allow changes to the descriptor file, use the insert command; find and delete the original line that reads "ddb.thinProvisioned = "1"." A thin disk was not vmdk. If it was, keep this sentence. To save your work and quit the "vi" editor, use ":wq!"
- 9. Run the following command against the disk descriptor file to examine the disk chain for consistency:
vmkfstools -e filename.vmdk
How to Recover Missed VMDK Descriptor File
Sometimes called the “header” file, the VMDK descriptor file – which saves crucial information about VMware virtual machines – may get corrupted due to many reasons. It can also be mistakenly deleted by a user. You know the VMDK descriptor file is missing when you start seeing the following error messages:
- Failed to open disk
- The file specified is not a virtual disk (15) 3023
- Cannot open the disk or one of the snapshot disks it depends on
- The file specified is not a virtual disk
When you start seeing any of these error messages, you should consider recreating the descriptor file, as that is one of the surest ways to fix and recover a corrupt VHDX file. The guide below works for people who use VMware Workstation or Server – people who can access and use the vmware-vdiskmanager utility. The tip is to create a new disk of the same type and size as the one with the missing header file.
- On Windows systems, go to the install directory of VMware Server or VMware Workstation - usually C:/Program Files/VMware/ - to launch the utility tool.
- Run the following command vmware-vdiskmanager.exe create disk size adapter disk-type path
Replace the bracketed parameters with the actual numbers of your disk, server, etc. For example, let’s create a 30 GB persistent disk on Windows Server 2003 on drive “f.” The command would be vmware-vdiskmanager.exe -c -s 30GB -a lsilogic -t 2 “f:\newdisk.vmdk”
- When you’re done creating the new disk, copy its VMDK descriptor file to the folder of the former disk (Virtual Machine) whose header file is missing or corrupted, then edit and point the flat file to the correct name.
Recreating a Missing Virtual Disk (VMDK)
This guide is for recreating a missing descriptor file for delta disks. But first, you have to validate if the VM directory contains another delta disk descriptor file or base disk’s descriptor file you can use as a template.
drwxr-xr-x 1 root root 1400 Nov 16 09:39 .
drwxr-xr-t 1 root root 2520 Nov 16 09:32 ..
-rw------- 1 root root 32768 Nov 17 19:11 testvm-000002-delta.vmdk
-rw------- 1 root root 32768 Nov 17 19:11 testvm-000002.vmdk
-rw------- 1 root root 32768 Nov 16 14:39 testvm-000001-delta.vmdk
-rw------- 1 root root 32768 Nov 16 14:39 testvm-000001.vmdk
-rw------- 1 root root 16106127360 Nov 16 09:32 testvm-flat.vmdk
-rw------- 1 root root 469 Nov 16 09:32 testvm.vmdk
-rw------- 1 root root 18396 Nov 16 14:39 testvm-Snapshot1.vmsn
-rw------- 1 root root 18396 Nov 17 19:11 testvm-Snapshot2.vmsn
VMDK recovery notes:
The highlighted files (in red) are the descriptor files to serve as a template or base. If the base descriptor file (or testvm.vmdk) is missing, you have to recreate it. But, if you can see more delta files with intact descriptor files, you can copy them as a template.
Also, you should ensure that character encoding for any files modified outside of your ESXi/ESX host console or SSH session is UTF-8; any other encoding format will result in failed processes.
VMDK recovery guide:
We have the first disk (disk.vmdk) in datastore1 and a second disk (disk_1.vmdk) in datastore2. A snapshot for the first disk (disk-000001.vmdk) and a snapshot for the second disk (disk_1-000001.vmdk). If the descriptor file for delta disk testvm-000001.vmdk is missing and its associated delta file testvm-000001-delta.vmdk is not corrupt or missing, to recreate the delta descriptor file, simply copy the current base disk descriptor file testvm.vmdk with the name of the missing descriptor file testvm-000001.vmdk:
# cp testvm.vmdk testvm-000001.vmdk
You can also modify this new snapshot delta descriptor file from being a base disk descriptor file to a snapshot delta disk descriptor file.
How To Recover VMDK Files Easily
If your VM’s VMDK file is missing, you can easily recover the file using a professional software solution – DiskInternals VMFS Recovery. This software program is the go-to solution for recovering lost data on any VMware virtual machine. It supports VMware vSphere, ESXi/ESX Servers and VMFS drives stored on all types of RAID arrays including RAID JBOD, 0, 1, 1E, 0+1, 1+0, RAID 4, RAID 5, 50, 5EE, 5R, RAID 6, 60.
Being a data recovery tool, DiskInternals VMFS Recovery:
- recovers information from corrupted or healthy VMFS-formatted drives
- recovers remotely in online mode (no shutdown is required)
- recovers VMFS drives stored on corrupted and inaccessible hard drives
- features a built-in Recovery Wizard and supports different recovery modes.
Using VHD recovery tool is very simple, even novice PC operators can use the app.
Tip: learn about VMware orphaned VMConclusion
The VMDK descriptor file is very important because it contains relevant information required by virtual machines. To recover missing VMDK descriptor files doesn’t really need third-party software. However, if you can’t find the VMDK file itself, you can retrieve backup - data recovery DiskInternals VMFS Recovery will help!