VMware Cloud Community
AnnettaC
Contributor
Contributor

Ineed some help recovering VMDK file.

A few weeks ago, my VCenter Server had a snapshot that was so large that it corrupted my VM while trying to remove it. I decided I could just reload the VM as it was only Virtual Center Server. However, I wanted to save one drive as it had some important information. I copied the vmdk to another datastore and reloaded my VM.  Then I tried to access the saved VMDK by adding it as a new hard drive. This fails with error:  Failed to Lock the file myfile.vmdk  Cannot open the disk myfile.vmdk or one of the snapshot disks it depends on. 

My server is on a closed network and I am unable to attach the log files.

I tired searching the net but have been unable to find a solution. 

Thanks in advance to whomever can help me.

Reply
0 Kudos
9 Replies
a_p_
Leadership
Leadership

Welcome to the Community,

without any logs or metadata files it's not easy to help, but let's see what's possible.

Basically each virtual disk (parent disk as well as snapshot disks) consists of two files, although you will only see one in the datastore browser. To see all of the files you need to access the datastore via e.g. WinSCP. The data files have "flat" or "delta" in their names, whereas the metadata/descriptor files are named <vmname>.vmdk for the parent disk, and <vmname>-00000x.vmdk for snapshot disks. What's important, is to understand how these files are chained together. Each of the snapshot metadata files have entries for their parent disks ("parentFileNameHint" as well as "parentCID"). It's necessary that the "parentCID" matches to "CID" of its parent virtual disk file, and that the .vmdk metadata/descriptor file name for the most recent snapshot (the last one in the chain) is used in the VM's configuration.

André

Reply
0 Kudos
AnnettaC
Contributor
Contributor

Andre,

thank you for the informaiton.  I am going to go out on a limb here and say I have really messed by saving only the one vmdk file.  Because the datastore where the vm was stored ran out of space.. the snapshot grew to large.. and to reload it, I removed all the other files after saving the vmdk off to another datastore. 

thanks for your time and help.

Annetta

Reply
0 Kudos
sajal1
Hot Shot
Hot Shot

Hi AnnettaC,

To further explain Andre's reply. You can restore os re-use the file in this scenario only when you have the parent vmdk. If you have parent vmdk and deleted the snapshot disks then also by modifying the parent vmdk descriptor file we would be able to restore/reuse the parent disk. But if the parent disk is deleted and you are left with snapshot files then it will not be possible to reuse it (as it depends on the parent disk). So in short parent disks can be used withtout the snapshot disks, but same is not true for snapshot disk.

So depends which vmdk file you deleted. Depending on that we can restore or can not restore.

AnnettaC
Contributor
Contributor

saja1,

After reading Andre's reply, I do not know which file I actually have. The parent or the snaphot.  The file have is named <vmname>_2.vmdk. I do not have anything with <delta> or <flat> in the file name.  It was thin provisioned and looks to be 14GB used of 200GB provisioned. It should have been the 2nd disk of three.  If I  have the parent and you can help me recover it I will really appreciate it.

Reply
0 Kudos
sajal1
Hot Shot
Hot Shot

Hello AnnettaC,

Please check the following KB articles on same:

VMware KB: Recreating a missing virtual disk (VMDK) descriptor file for delta disks

VMware KB: Recreating a missing virtual machine disk descriptor file

The above would give you some idea about how these works.

In short you will not be able to see them from the Datastore browser view. You need to go to command prompt (SSH or Direct Console). From there go to the Datastore directory which contains the VM files. Now there if you run "ls -l" or simple ls you would be able to see both the files. For example of a VM named example, you should be able to see the following two files (assuming there is only one disk).

example.vmdk   -------> this is in KB only and called the descriptor file

example-flat.vmdk -----> this is the actual data file which holds the data and would be equal to the disk size (if thin provisioned then equal to actual size, otherwise full disk size).

So you need to check the vmdk (descriptor) file only (if it exists).

It should have two fields CID and parentCID. CID is the ID of the file itself and the parentCID is the CID of the parent file.

In case the file itself is parent disk then parentCID field would always be ffffffff.

If the vmdk file has snapshots then the second disk in chain would have CID of the parent disk as the parentCID in the filed.

So now you need to check this descriptor file to determine the state.

Hope this is clear now.

AnnettaC
Contributor
Contributor

Hi Saja1,

I have read these KBs but I am unsure how to connect to my datastore with WINSCP.  when I try to connect I get connection refused.  I will continue to try to access and reply back with my results.

Thanks

annettac

Reply
0 Kudos
sajal1
Hot Shot
Hot Shot

Hello AnnettaC,

You can transfer file to and from ESXi host using WinSCP. To access it you need something like putty.

From the Direct Console of ESXi, login and go to Troubleshooting Option --> Enable SSH or Enable ESXi Shell

Once you enable SSH, then you can use Putty to SSH to ESXi host. Once you are connected to ESXi host through Putty then you can access the files.

Reply
0 Kudos
AnnettaC
Contributor
Contributor

OK.  I didn't think of this.  SSH is already enabled. I just need to go to the server room tomorrow and check it out.

Thanks for all your help!

Reply
0 Kudos
AnnettaC
Contributor
Contributor

Sajal1,

I was able to log in and search the datastore but did not find my files.  I have given up on try to recover them but I thank you and Andre for your help.  Next time I will be more careful with my deleting..

AnnettaC

Reply
0 Kudos