Konstantin Emelyanov - Fotolia

Can a VMware snapshot resurrect a VMDK file?

Snapshots can be used to undo botched upgrades, but can they be used to rebuild a broken VMDK file?

When troubleshooting whether it's possible to recover a lost base VMDK file using a snapshot, it helps to look...

at how VMDK files and snapshots work within vSphere.

How snapshots work

When we take a VMware snapshot, we don't actually duplicate any data from the original disk. Instead the original disk is placed into a read-only state and a new redo log -- sometimes called a delta disk -- is created. This delta disk is a placeholder for any writes occurring on the VM from that point forward.

Delta file
Figure 1: The delta file contains just the changes made after the snapshot is made.

Figure 1 helps illustrate how the snapshot process works. Imagine a disk holding the word "SNAPSHOT" with each letter residing in its own block. When we take a snapshot of the disk, the original word becomes read-only and a new delta VMDK is created. The second block is changed to "L" and an "S" is added in the ninth block to create the new word "SLAPSHOTS."

With all files intact, we have a couple of options. We could delete the snapshot, which would simply merge the new blocks into the original VMDK and commit "SLAPSHOTS" to our VM -- or we could revert to a point in time, meaning we could revert back to when the disk read "SNAPSHOT." Each time a snapshot is created, a new delta disk is made, meaning we could revert to any point in the snapshot chain.

A doomed rescue mission?

If the original VMDK gets corrupt or deleted, a lot of challenges are presented. As you can see in Figure 2, the original disk containing the word "SNAPSHOT" is gone. What we are left with now is a delta disk which contains the letters "L" and "S," with metadata pointing to a disk that no longer exists.

Missing VMDK
Figure 2: With only a snapshot of a broken or missing VMDK file, there is no way to rebuild the original file.

As you can probably conclude, without the original disk or the original blocks containing "SNAPSHOT," there is no way to reconstruct anything with the partial data left in the delta file.

Recovery depends on what is missing

Recovering a lost base VMDK from just a snapshot file is not possible, but depending on which base VMDK file is lost you may have some options. A virtual machine disk is made up of two different files; the -flat .VMDK file -- the most important portion of the virtual disk -- holds all the data and is a descriptor file that tells the virtual machine's configuration file -- the .vmx file -- all about its respective disk.

If the -flat.VMDK file is lost, there isn't much you can do except hope a backup exists. If the descriptor file is missing, then you can use the ESXi command line to perform a recovery. See VMware's knowledge base article 1002511 for the steps to perform this.

Next Steps

VMware increases maximum limit for VMDK file size

Four virtual disk formats VDI admins should know

How to move VMDK files over a VM to a client

Dig Deeper on VMware ESXi, vSphere and vCenter

Virtual Desktop
Data Center
Cloud Computing
Close