VMware Cloud Community
chchang
Contributor
Contributor
Jump to solution

how to restore data from *-delta.vmdk without *-flat.vmdk ?

due to some reason , I have a abc-00002-delta.vmdk and no other files ( no VMX . no abc-0002-flat.vmdk)

is there any way to mount this vmdk in windows to recover files ?

or any way to mount this vmdk in vsphere ?

I tried to create a new VM and attach the vmdk , there is a error messages

"cannot open the disk '*.vmdk' or one of the snapshot disk is depends on"

1 Solution

Accepted Solutions
a_p_
Leadership
Leadership
Jump to solution

That's an unusual disk size, which is usually a result of a P2V conversion. Anyway, this doesn't matter much, but we will need to create the base virtual disk from the command line.

What's more important is the partition type and the alignment. Unless you know this, I'd suggest you do a first try with an "MBR" partition type, and a "NTFS" formatted "Basic" partition. I'd also suggest you use the default cluster size while formatting the disk, although best practices recommend another cluster size for SQL server.

The good news is that chances to restore files are high due to the size of the delta file, which almost reaches the virtual disk's provisioned size.

Here are the steps:

  • enable SSH on the ESXi host, and login via e.g. putty
  • go to the folder with the delta file: cd /vmfs/volumes/<datastore-name>/sql2008-erp
  • make sure that neither sql2008-erp.vmdk nor sql2008-erp-flat.vmdk already exist!!!
  • create a new virtual disk: vmkfstools -c 41945715k  sql2008-erp.vmdk -d thin
  • attach the newly created virtual disk to a helper VM, and format it as mentioned above
  • shut down the helper VM
  • run cat sql2008-erp.vmdk and make note of the "CID" value
  • replace the "parentCID" value with the above noted value in the attached sql2008-erp-000002.vmdk file
  • upload this file to the VM's folder on the datastore
  • edit the helper VM's configuration (.vmx) file, and replace sql2008-erp.vmdk with sql2008-erp-000002.vmdk
  • reload the .vmx file as explained in Reloading a vmx file without removing the virtual machine from inventory (1026043) | VMware KB
  • create another snapshot to ensure that the data in the delta file doesn't get modified
  • power on the VM and check the result

Note:

To edit the attached .vmdk file, either use an editor which can handle unix line breaks, or upload the file first, and then use the vi editor to edit it. If you are going to use WordPad, make sure that you select .txt as the file format when you save the file!!!

André

View solution in original post

10 Replies
OptimusP
VMware Employee
VMware Employee
Jump to solution

Sorry, I don't think that's possible. You need the original -flat vmdk file.

0 Kudos
a_p_
Leadership
Leadership
Jump to solution

So you only have the delta.vmdk file, i.e. no other .vmdk files?

As you may know, delta files only contain changed blocks/sectors. However, it should be possible to extract at least some data from the snapshot/delta file (the larger the delta file, the larger are chances to recover data).

For this to work you need to know the exact provisioned size of the virtual disk. With this information, create a new virtual disk with this size as an additional virtual disk on a helper VM, and format it the same way as the original disc was formatted (e.g. MBR vs. GPT, Basic disk, ...). Then create the descriptor .vmdk file for the snapshot (settings can derived from the base disk's descriptor .vmdk file's contents). Make sure that "parentCID", and "parentFileNameHint" point to the correct values. Once done, edit the VM's .vmx file, so that it points to the snapshot/delta descriptor .vmdk file, and don't forget to reload the VM after doing this (see Reloading a vmx file without removing the virtual machine from inventory (1026043) | VMware KB). If the VM comes up, you may use a file recovery tool to search for files on the recreated virtual disk.

If you need help, then download the delta.vmdk file to your PC, and use the XLS file which I posted at Corrupt redo log freezing VM. Note that the Macro may throw an error. However, it should at least create the "Header Definition" tab which contains the important information. If this is the the case, then please attach the resulting XLS file to a reply post.

André

0 Kudos
chchang
Contributor
Contributor
Jump to solution

here is the header info

FilenameC:\VM\sql2008-erp-000002-delta.vmdk
Filesize41,137,819,648
CompatibilityVMware ESX Server
#define COWDISK_MAX_PARENT_FILELEN  1024
#define COWDISK_MAX_NAME_LEN        60
#define COWDISK_MAX_DESC_LEN        512
OffsetLenghtValueDezimalDescription
typedef struct COWDisk_Header {
unint32magicNumber;0444 57 4F 43COWDThis magic number is used to verify the validity of each sparse extent when the extent is opened
unint32version;4400 00 00 011The value of this entry should be 1
unint32flags;8400 00 00 033Bit 0: valid new line detection test, bit 1: redundant grain table will be used, bit 16: the grains are compressed
unint32numSectors;12405 00 14 E683,891,430Refers to total number of sectors on the base disk.
unint32grainSize;16400 00 00 011Refers to the granularity of data stored in delta links, which is one sector by default. Can vary from one sector to 1MB
unint32gdOffset;20400 00 00 044Starts at the fourth sector, because the COWDisk_Header structure takes four sectors
unint32numGDEntries;24400 00 50 8020,608Is CEILING(numSectors, gtCoverage)
unint32freeSector;28404 C9 EC AE80,342,190Is the next free data sector. This needs to be less than the length of the delta link. It is initially set to gdOffset + numGDSectors
union{...} u;321028unused
unint32generation;1060400 00 00 000
charname[60];106460unused
chardescription[512];1124512unused
unint32savedGeneration;1636400 00 00 000Is used to detect the unclean shutdown of the delta link. It is initially set to 0
charreserved[8];16408unused
unint32uncleanShutdown;1648400 00 00 000Is used to trigger the metadata consistency check in case there is an abnormal termination of the program
charpadding[396];1652396
} COWDisk_Header;
0 Kudos
a_p_
Leadership
Leadership
Jump to solution

That's an unusual disk size, which is usually a result of a P2V conversion. Anyway, this doesn't matter much, but we will need to create the base virtual disk from the command line.

What's more important is the partition type and the alignment. Unless you know this, I'd suggest you do a first try with an "MBR" partition type, and a "NTFS" formatted "Basic" partition. I'd also suggest you use the default cluster size while formatting the disk, although best practices recommend another cluster size for SQL server.

The good news is that chances to restore files are high due to the size of the delta file, which almost reaches the virtual disk's provisioned size.

Here are the steps:

  • enable SSH on the ESXi host, and login via e.g. putty
  • go to the folder with the delta file: cd /vmfs/volumes/<datastore-name>/sql2008-erp
  • make sure that neither sql2008-erp.vmdk nor sql2008-erp-flat.vmdk already exist!!!
  • create a new virtual disk: vmkfstools -c 41945715k  sql2008-erp.vmdk -d thin
  • attach the newly created virtual disk to a helper VM, and format it as mentioned above
  • shut down the helper VM
  • run cat sql2008-erp.vmdk and make note of the "CID" value
  • replace the "parentCID" value with the above noted value in the attached sql2008-erp-000002.vmdk file
  • upload this file to the VM's folder on the datastore
  • edit the helper VM's configuration (.vmx) file, and replace sql2008-erp.vmdk with sql2008-erp-000002.vmdk
  • reload the .vmx file as explained in Reloading a vmx file without removing the virtual machine from inventory (1026043) | VMware KB
  • create another snapshot to ensure that the data in the delta file doesn't get modified
  • power on the VM and check the result

Note:

To edit the attached .vmdk file, either use an editor which can handle unix line breaks, or upload the file first, and then use the vi editor to edit it. If you are going to use WordPad, make sure that you select .txt as the file format when you save the file!!!

André

chchang
Contributor
Contributor
Jump to solution

thanks for reply

But the vm host is disconnect in Vcenter and not able to connect due to some SSL error messages

I will try to reconnect the host and follow your step  if the vm host will be connected .....

0 Kudos
chchang
Contributor
Contributor
Jump to solution

my first try , after format the disk with MBR/ntfs/default cluster ,  the rescure VM with the delta disk attached is able to boot , but cant read any files, and in the disk mgmt panel , the disk size is unknown .

so I remove the snapshot , remove the disk (from VM and datastore) , upload again and try dynamic Disk , format as NTFS , reboot , wait for chkdsk to check and fix the disk complete(almost 2 hours) , and all datas come back !

thanks for your help !

0 Kudos
2679
Contributor
Contributor
Jump to solution

I have almost the same issue.  Flat.vmdk exist and snapshot file exist.  But unable for vm to boot using delta.vmdk.  I can only boot up using the flat file.

I have no clue on your issue and how you were able to resolve this issue.  I would love to have help in this.

Thanks.

0 Kudos
tungttt23
Contributor
Contributor
Jump to solution

Sorry to bother you with this, but can i ask how do you determine the size of the new virtual disk with the -c option when creating the new disk?

"create a new virtual disk: vmkfstools -c 41945715k  sql2008-erp.vmdk -d thin"

I also only have the delta.vmdk file, with no flat.vmdk file, and when i followed your guide it failed to start in the end, putting out an error saying that the disk can't be opened because the capacity of the parent disk and the child disk is different.

Attached is my info using your script.

I would greatly appreciate your help, thanks a lot.

0 Kudos
a_p_
Leadership
Leadership
Jump to solution

The "numSectors" represent the virtual disk's provisioned size in sectors (512 Bytes/Sector). You should see the same value in the snapshot's descriptor file. If you divide that value by 2 you'll get the provisioned size in kB.

André

tungttt23
Contributor
Contributor
Jump to solution

Thanks a lot for the explanation, i will try the correct parameter and see if it can recover my data.

Have a nice day.

0 Kudos