ITExperience.NET Rotating Header Image

Howto: Recreate VMDK files



On VMWare ESX3, your VM has one or more VMDK files (extension .vmdk) and one or more flat vmdk files (last characters flat.vmdk )

In some cases, you may corrupt, lose or accidentally delete your VMDK files. Your VMDK’s contain metadata for your flat.vmdk files. Without your VMDK’s, you cannot load your flat.vmdk-files. Consequence: you cannot load the VM in your VirtualCenter and you cannot start the VM.
The following steps will guide you to recreate your vmdk files (.vmdk):

  1. Determine the hard disk sizes of your original VM (I call this VM from now on: VM A)
  2. Create a new VM (I call this VM from now on: VM B) with VirtualCenter with the same number of hard disks as your old VM, and the exact same sizes. So: if your original VM contained 2 harddisks from 8,00GB and 12,00GB, recreate these harddisks exactly the same in your new VM.
  3. After your VM B has been created, use Putty (or a similar tool) to navigate to your ESX server. Then navigate to the location / directory where your VM B is stored.
  4. Copy all VMDK’s (not the flat ones, but only the metadata files) to your VM A directory. The filesize of your META-data files should be a few KB.
  5. Navigate to your VM A directory. You just copied the *.VMDK files to this directory. Edit the VMDK’s with a text editor: You should replace the old filenames with the correct file names -> They refer to the new VM B, but they should refer to your old (original) VM A
  6. Save the files.
  7. Load the VM in your VirtualCenter. You should now be able to add th flat.vmdk to your VM.

Is it still not working? Leave a comment, so I (or another visitor) can assist you!

43 Comments

  1. timhoa says:

    Thanks a lot. A little trick that saved a lot of work!  

    (Quote)

  2. Ton says:

    I meant Zack offcourse

    Ton: Thanks Salvatore, your trick did it, smooth and easy,
    Thanks all for your help, i thought i had destroyed a lot of data of one of my customers !
      

      

    (Quote)

  3. Ton says:

    Thanks Salvatore, your trick did it, smooth and easy,
    Thanks all for your help, i thought i had destroyed a lot of data of one of my customers !

    Salvatore: Great!!
    This was the trick that fixed my issue :-)
      

      

    (Quote)

  4. Georges says:

    Same as Kody (@Kody do u have solved your datas ?)
    I’ve just delete my 4 vmdk by choosing this “Delete from disk” function.
    Does anyone have any tricky solution for me ?
    I don’t shut down the ESXi4 yet.

    The 4 vmdk were store in a whole HDD. (just in case )

    Thanks any way:)  

    (Quote)

  5. There is a little easier way to do this with a slight change.

    1. Remove the VM from inventory if it is still in the list.
    2. Rename the VM Datastore folder to a new name.
    3. Recreate the VM with Disks of the same size and Name of the original missing VM.
    4. Once that is done go into the datastore and Move the two Flat.vmdk files into the folder of the new VM. It will warn you that it already exists. Just tell it to overwrite the files.
    5. Power the VM back on and you are good to go.

    This worked for me last night before I saw this article, so I thought I would share. It doesn’t require you to go in and edit the metadata file.  

    (Quote)

  6. Will says:

    Saved me a call to Vmware tech support… Cheers  

    (Quote)

  7. bizarro stormy says:

    It worked! Thank you very very much.  

    (Quote)

  8. Nocte says:

    Thank you so much !

    This article works also for esx 4 too (Before I found this howto, I used datastore browser to copy/paste the flat vmdk, but VM don’t start… Command line is really needed, or I missed something).  

    (Quote)

  9. adastra says:

    hi
    very nice article, mutch thx.
    But is there a way to recover a deleted snapshot too?  

    (Quote)

  10. Ryan says:

    Worked perfectly thank you!  

    (Quote)

  11. Millman says:

    Worked like a charm! Only thing I also removed were the Delta and Snapshot files.
    But I think nothing was changed on the machine so I was lucky!

    Tried to remove the snapshots via the Snapshot manager but that didn’t work.
    Had to remove the machine from inventory and add it again.
    (double-clicked vmx file in datastore folder)

    Thanks for explaining!  

    (Quote)

  12. waxs says:

    Thanks very very much bro..
    you save my day! i can up my virtual backup server within than 30 minutes!

    Thanks and your rock!  

    (Quote)

  13. Thorn says:

    Great article, which saves me a lot of nervous!
    And damn… WTF those idiot$ from VMWare made sh*t like this?? Why if you have a normal -flat file you cannot just join it?!?! Hate those stupids.  

    (Quote)

  14. Salvatore says:

    Great!!
    This was the trick that fixed my issue :-)

    Zack: You can also use the VCenter Datastore Browser. Browse to the folder and choose to download the .vmdk file. It will start downloading both files, just make a copy of the 1KB .vmdk file and cancel the transfer before the big data file finishes. Edit the .vmdk in notepad, rename it, and upload to the original location.

      

    (Quote)

  15. Mandy says:

    Just as an FYI in case someone runs into a similar issue, I was able to recover the files I needed off of my vmdk file using ZAR

    http://www.z-a-recovery.com/download.htm  

    (Quote)

  16. Mandy says:

    My ESXi 4 server crashed last Friday, because of a faulty RAID controller. I replaced the RAID controller, then rebooted the host. All VMs came up fine except for one. When trying to turn on this VM I get the following error message

    Cannot open the disk
    ‘/vmfs/volumes/48c97126-5358220d-8410-001d09683800/Test/Test-000002.vmdk’
    or one of the snapshot disks it depends on.
    Reason: No child processes.

    I have tried what was suggested in this article and still got the same error. Any ides?  

    (Quote)

  17. getupaaaah says:

    Wowieeeeeeee, I’m not a crack at VMWare but was willing to trie. And deleted in hurry (yeah I know that’s not smart) the files at my own homeserver. Except for the VMDK file. And was able rebuild it by using this thread. Problem solved !!!!!!
    Thanks a lot lot lot lot.  

    (Quote)

  18. Semion says:

    Thanks man i think its the only way to duplicate VMs if you work with ESXi free license and no VCenter involved  

    (Quote)

  19. Jano says:

    Thank you for the information !  

    (Quote)

  20. Stephane says:

    Woot! It works!  

    (Quote)

  21. Kat says:

    Hmm…what if the main .vmdk has spaces in it. So all files are “Windows XP.vmdk” and “Windows XP-f___.vmdk”. Is there a problem with that. Im still getting an error  

    (Quote)

  22. Brett says:

    I had esxi install and had a datastore with all of my virtual machines vmdk files. I upgraded my version of esxi to from update 2 to update 3. After the install my storage showed that one of my disks was unhealthy and marked it offline. I replaced the disk in the RAID 5 configuration and did a rebuild of the disk. Once this was completed I logged in via VI client and I could not see the 410GB lun if I go and add storage I can see the LUN but it wants to format the LUN which I don’t want because I will loose my VMDK files. Someone said I should go into advanced settinggs and click oon LVM and change the LVM.Volume.Resignaturing value to a 1 and then rescan and the LUN should show up but that did not work. Does anyone have any ideas as to how I can get that LUN back or the data from the LUN?
    Thanks a mil
    Brett  

    (Quote)

  23. Zack says:

    You can also use the VCenter Datastore Browser. Browse to the folder and choose to download the .vmdk file. It will start downloading both files, just make a copy of the 1KB .vmdk file and cancel the transfer before the big data file finishes. Edit the .vmdk in notepad, rename it, and upload to the original location.  

    (Quote)

  24. Walid says:

    whhhooooo

    you rock  

    (Quote)

  25. Ido says:

    Its Work!!! I can’t belive it….

    You just made my day..

    Thanks alot!!  

    (Quote)

  26. Tedson says:

    The process you provided worked flawlessly. I was able to recover one SQL server in a 3.0.1 environment. Too bad I had mistakenly deleted the files AND directory for another one… and then wrote over the disk with a new 500GB disk file… otherwise I could have recovered two servers today! Thank you kind sirs for your help!
    :)  

    (Quote)

  27. pritam says:

    It worked men…Thanks for the help  

    (Quote)

  28. Maurice says:

    Yeah, the ESX console is linux (red-hat?) based. You need to login, but can’t do it using the puTTY terminal software, unless you’ve already created a user authorized to login via telnet, SSH, whatever.

    So create a valid user not root – do this on the console (or Virtual Center console tab?). Use PuTTY (download through putty.org) to connect over the network using telnet or SSH to the VMware ESX console IP addr, login, then use “sudo” to become the root for any commands you need (or you will have to change the permissions on the files to be allowed to see/copy them…)  

    (Quote)

  29. Maurice says:

    Aha. A co-worker found the solution. We have VMware ESX 3.5 (not “i”). There was some note in documentation about how the disk database tracks valid LUNs – and will not allow you to mount a snapshot (obviously, to prevent accidental data corruption).
    I assume somehow my valid disk got seen as a snapshot (-flat.vmdk) when the VMDK file disappeared?
    Anyway, the Virtual Center browser did not show the small VMDK files on active machines, just 40GB VMDK if the machine was working. Huh?

    Turns out, VC datastore browser treats the pair of files (.vmdk and flat.vmdk) as a single file shown only as the non-flat file.

    To see the individual files separately, you must use the ESX console, the linux-based interface. Then you can do LS, CP, etc. You can find and copy the recreated small descriptor vmdk files to alongside the existing flat.vmdk and tada! – a disk you can mount to a virtual machine.  

    (Quote)

  30. Kelvin says:

    Works like a charm.

    Thanks loads  

    (Quote)

  31. Maurice says:

    I had a problem where, after shutting down a VM and doing a “migrate storage location” – the machine came back up but After a little while I could not reach the console. (RDP still worked).

    I shutdown for reboot from remote console, and it would not reboot – file error.

    Examination showed VMX and VMDK files gone, disks are now FLAT.VMDK – but I have ESX 3.5 and this does not appear to create VMDK text files, the VMDK in any valid machine is the full XX GB of the disk image; no FLAT file associated.

    Is this something new in ESX 3.5?  

    (Quote)

  32. PiNG says:

    Hi.
    I’ve exactly the same problem.
    I’ve create the new VM. Unfortunately, I know nothing about PuTTY.
    I’ve downloaded them but I don’t know what you mean.
    Could you please explain step by step in PuTTY.
    Thx a lot  

    (Quote)

  33. HND says:

    You may use GDB getdata back or PCI filerecovery tool to get ur deleted files back. It gives almost 100% sucess if you apply these tools immediatly after you accidentaly deleted the files.
    Immedatly means NOT real time. It means b4 you write any thing to ur HDD again (which will re-use ur sectors of HDD where deleted files are )

    HND  

    (Quote)

  34. Kody says:

    I accidentally use the “Delete from disk” function and wipe out my entire vm machine. There are 2 drives. The first is 20gb and the second is 1TB. The second drive is where all my data located. It is possible to recover the main vmdk file for the second drive? I browsed the data store and everything is gone including the directory that holds the files for that vm. Thanks.  

    (Quote)

  35. ElMehdi says:

    hello,
    I wanted to thank you for your article, like others you saved me a lot of time.

    Regards,
    ElMehdi  

    (Quote)

  36. Roman says:

    Hi,

    Nevermind, I just removed the template and added it again, it works now, thanks!

    Cheers,
    Roman  

    (Quote)

  37. Roman says:

    Hi,

    I can do all your steps described in the initial post, but I am not able to add the flat.vmdk because it’s a template and not a vm. Is there also a solution to get this fixed?

    Thanks,
    Roman  

    (Quote)

  38. david says:

    thanks, you saved my bacon!!  

    (Quote)

  39. Chad says:

    An error said that the disk was corrupted and was not a virtual disk.
    The log says that Windows XP Professional-000003.vmdk is corrupted. It is 0kb in size. It used to be 2.7GB.
    How do I recover the file. The last snapshot I have is from 4 months ago. (I know. Stupid on my part.)

    Here is a section of the log:
    ————————————-
    Jul 04 01:21:05: vmx| ACL_InitCapabilities: here 1 (bug 63252)
    Jul 04 01:21:05: vmx| changing directory to f:\virtual machines\windows xp professional\.
    Jul 04 01:21:05: vmx| Config file: f:\virtual machines\windows xp professional\windows xp professional.vmx
    Jul 04 01:21:05: vmx| Unable to find file Windows XP Professional-000003.vmdk
    Jul 04 01:21:05: vmx| Unable to find file Windows XP Professional-000003.vmdk
    Jul 04 01:21:05: vmx| DISKLIB-LINK : “Windows XP Professional-000003.vmdk” : failed to open (The file or directory is corrupted and unreadable).
    Jul 04 01:21:05: vmx| DISKLIB-CHAIN : “Windows XP Professional-000003.vmdk” : failed to open (The file or directory is corrupted and unreadable).
    Jul 04 01:21:05: vmx| DISKLIB-LIB : Failed to open ‘Windows XP Professional-000003.vmdk’ with flags 0×17 (The file or directory is corrupted and unreadable).
    Jul 04 01:21:05: vmx| DISK: Cannot open disk “Windows XP Professional-000003.vmdk”: The file or directory is corrupted and unreadable (91226121).
    Jul 04 01:21:05: vmx| DISKUTIL: GetDevVersion: couldn’t open file ‘Windows XP Professional-000003.vmdk’ : The file or directory is corrupted and unreadable (91226121).
    Jul 04 01:21:05: vmx| DISKUTIL: Could not populate version buffer.

    —————————————–

    Here are the files in the directory:

    06/28/2008 12:02 PM 8,664 nvram
    01/25/2008 08:31 PM 0 Windows XP Professional (2).vmdk.lck
    07/04/2008 09:50 AM 20,897 vmware.log
    07/04/2008 01:21 AM 20,900 vmware-0.log
    07/04/2008 01:20 AM 69,057 vmware-1.log
    06/28/2008 06:21 AM 33,056 vmware-2.log
    01/25/2008 08:33 PM 443 Windows XP Professional (2).vmdk
    06/28/2008 12:02 PM 443 Windows XP Professional (3).vmdk
    02/11/2008 10:12 PM 443 Windows XP Professional (4).vmdk
    02/14/2008 08:15 PM 444 Windows XP Professional (5).vmdk
    02/14/2008 08:20 PM 416 Windows XP Professional (6).vmdk
    02/14/2008 08:20 PM 417 Windows XP Professional (7).vmdk
    06/28/2008 12:02 PM 443 Windows XP Professional (8).vmdk
    02/03/2008 11:03 AM 362 Windows XP Professional.vmdk
    01/26/2008 01:34 AM 0 Windows XP Professional-000002.vmdk
    07/04/2008 01:20 AM 0 Windows XP Professional-000003.vmdk
    02/03/2008 11:03 AM 12,884,901,888 Windows XP Professional-flat.vmdk
    06/27/2008 06:41 AM 268,435,456 windows xp professional.vmem
    02/03/2008 11:09 AM 268,435,456 windows xp professional-Snapshot3.vmem
    02/03/2008 11:03 AM 930 Windows XP Professional.vmsd
    02/03/2008 11:09 AM 18,395,040 windows xp professional-Snapshot3.vmsn
    06/28/2008 12:02 PM 18,000,730 windows xp professional.vmss
    06/28/2008 12:02 PM 1,513 Windows XP Professional.vmx

    Any help would be greatly appreciated. Thank you.  

    (Quote)

  40. admin says:

    Hi Nick,

    when you have deleted your flat.vmdk file, I’m afraid there’s nothing you can do besides recovering the machine from a backup (if you have one…). This is because your flat.vmdk files contain all data (not your meta-data, but the REAL data)  

    (Quote)

  41. Nick Pham says:

    Hi,

    I have accidently deleted my flat.vmdk files, but have my other expanding vmdk files. Is there a way to recover it? or recover any sort of data at all? Any data would be great!

    At the moment I have 4 files.
    name-000001.vmdk
    name-000001-delta.vmdk
    name-000002.vmdk
    name-000002-delta.vmdk

    Missing the flat.vmdk.

    Thanks in Advance.  

    (Quote)

  42. Michael Stone says:

    Thanks man! This article just saved my day. My VMDK was gone this morning. Had to recreate it. I’m glad I knew the disk sizes of my C and D partitions, I could remake that VMDK in a jiffy, and I was up and running again within 1 hour!  

    (Quote)

Leave a Reply

Comments without hyperlinks are immediately visible. However, if you post a comment that includes a hyperlink, your comment requires approval. This can take up to one day.