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!

You may also like...

62 Responses

  1. It’s a pity you don’t have a donate button! I’d
    most certainly donate to this brilliant blog! I guess for now i’ll settle for book-marking
    and adding your RSS feeds to my Feed reader account.
    I look forward to fresh updates and will talk
    about this blog with my Facebook group. Talk soon!

  2. Col says:

    Hi
    Can you help me i recieve error message in my VM

    states error caused by datastore-AD 000001.vmdk

    my VM that contain Domain controller of Server could not start up

    cheers

    Col

  3. Excuse me if I’m posting this in the wrong place, but does anybody on this page know where I can find opinions on a organization in the United states advertising an IT sales job? The company is LTJ Management, LLC located at 900 Congress Ave., Suite L-150, Austin, TX 78701 (512) 895-9500. I’m relocating to the US shortly and any help will be valued. Thank you.

  4. Scott@EMC says:

    I had the same issue. we had a problem with some of our Vms on esx4.1 that we had issues with when we upgraded esx to 5.0. we luckily used vcenter prior and had backups. but to get them back, we had to remove all the SAN attached devices, and during this process we accidentally deleted the base VMDK file. your procedure worked perfectly…

    1. created a new VM of same size disks as the VM you want to recover…
    2. copy the created vmdk file vmguest.vmdk to the datastore/vm folder of the vm you want to recover
    3. edit the vmdk file that you just copied over and chage: # Extent description
    RW 136314880 VMFS “solaris10b-flat.vmdk” to “solaris10-flat.vmdk” so it finds the right flat file…
    4. add the disk back into the VM again, this time it should see the vmdk file itself.
    5. start up the VM..

    in my case it worked perfectly, and then we cloned the Vm back to its original ESXi server.

    -s

  5. Support says:

    Great, thanks a million !

  6. Mark Hill says:

    This SO just saved our bacon, I can’t let you know how thankful we are!

    I just copied a .VMDK disk file from an existing VM with a same sized disk, renamed the file and edited the filename within the file and job done! *Phew*

  7. Jose says:

    Hi,
    I’ve made all you tell in this thread but always get the same error: “Reason: the file specified is not a virtual disk”
    Any advice?
    Thanks.

    • Jose says:

      Hi,
      I’ve made all you tell in this thread but always get the same error: “Reason: the file specified is not a virtual disk”
      Any advice?
      Thanks.

      Hi again,
      I’ve just created a new VM pointing to the “recreated” vmdk and get this errror:
      “Reason: The file specified is not a virtual disk.
      Cannot open the disk ‘/vmfs/volumes/4d4067a1-4e2cef13-f244-001ec9bb5f90/csm-bilbo/csm-bilbo.vmdk’ or one of the snapshot disks it depends on. ”

      What I’m doing wrong?

  8. Thankful User :) says:

    Oh my god…you just saved me hour and hours of restoring data. My issue occured when a VM tried to vmotion. It errored and one of the VMDK’s just vanished…wow…thank you!! :)

  9. Isuru Manikkage says:

    Thank you very much…
    This article saved me from big data loss.
    Now it is time for a pizza :-) Thanx again.

    Isuru Manikkage

    • Anonymous says:

      Great, thanks a million !

      This SO just saved our bacon, I can’t let you know how thankful we are!

      I just copied a .VMDK disk file from an existing VM with a same sized disk, renamed the file and edited the filename within the file and job done! *Phew*

      I had the same issue.we had a problem with some of our Vms on esx4.1 that we had issues with when we upgraded esx to 5.0.we luckily used vcenter prior and had backups. but to get them back, we had to remove all the SAN attached devices, and during this process we accidentally deleted the base VMDK file.your procedure worked perfectly…

      1. created a new VM of same size disks as the VM you want to recover…
      2.copy the created vmdk file vmguest.vmdk to the datastore/vm folder of the vm you want to recover
      3. edit the vmdk file that you just copied over and chage: # Extent description
      RW 136314880 VMFS “solaris10b-flat.vmdk” to “solaris10-flat.vmdk” so it finds the right flat file…
      4. add the disk back into the VM again, this time it should see the vmdk file itself.
      5. start up the VM..

      in my case it worked perfectly, and then we cloned the Vm ba

      Hi again,
      I’ve just created a new VM pointing to the “recreated” vmdk and get this errror:
      “Reason: The file specified is not a virtual disk.
      Cannot open the disk ‘/vmfs/volumes/4d4067a1-4e2cef13-f244-001ec9bb5f90/csm-bilbo/csm-bilbo.vmdk’ or one of the snapshot disks it depends on. ”

      What I’m doing wrong?

      Thank you very much…
      This article saved me from big data loss.
      Now it is time for a pizza :-) Thanx again.

      Isuru Manikkage

      ck to its original ESXi server.

      -s

  10. VG says:

    Thank you! Thank you! Thank you! Your instructions were spot on and saved me a lot of headache.

  11. userxp says:

    I use win XP sp3 and the _-flat.vmdk and _.vmdk files icons were little transparent like hidden files, when I clicked on these files they disappeared, the _-flat.vmdk is using 60Gb of space and is fully allocated. The file is in the hard disk partition, the system do not permit copy a file with same name there, but I can’t access the files, when I try to copy a file with the same there I get the “Do not have permission” message, I’m the administrator(winxp). I tried xcacls.exe from microsoft to change the permission but with no success. Now I wan’t to restore or either delete the _-flat.vmdk file, without formating the partition .

  12. ravi prakash says:

    i have installed SAP IN my laptop it was working fine but after some days it showing message like running low disk space so i did defragmentation and compressed the disk later i am getting error when i try to connect to vmware

    We’re running VMware Server 5.x as the host, and Windows 2003 as the guest. We started getting the error message below. when i try to start virtual machine i am getting the message below.suggestions on tools to check the consistency or repair the vmdk file?
    Operation on file “E:\ECC 6 VM Ware\ windows Server 2003 ECC 6VM.vmdk” failed (Read beyond the end
    of file).
    Choose Retry to attempt the operation again. Choose Abort to terminate
    this session.
    Choose Continue to forward the error to the guest operating system.

    I don’t understand how to get rid of thios issue pls any one help me in this issue.
    Ravi

  13. Will Richardson says:

    Thanks for that, you’ve saved me a lot of pain, I managed to delete the config files whilst the VM was running but this article has saved me a ton of work. Thanks!

  14. Mitry says:

    Hi friend!
    Today i have exactly the same situation – fail disk in RAID5 and this error after replace.
    Please if you found some solution – let me know.

    Mandy: 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 messageCannot 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?  

  15. Cesar G says:

    Hi,

    I just try this how to and it works!!!, very nice and easy to do. my Os is windows 2008 64bit. and it works!!, same me a lot of work.

    thanks,

  16. chabi says:

    Thx you saved my life, it’s awesome !!!

  17. timhoa says:

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

  18. 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 !
      

  19. 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 :-)
      

  20. 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:)

  21. 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.

  22. Will says:

    Saved me a call to Vmware tech support… Cheers

  23. bizarro stormy says:

    It worked! Thank you very very much.

  24. 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).

  25. adastra says:

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

  26. Ryan says:

    Worked perfectly thank you!

  27. 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!

  28. 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!

  29. 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.

  30. 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.

  31. 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

  32. 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?

  33. 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.

  34. Semion says:

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

  35. Jano says:

    Thank you for the information !

  36. Stephane says:

    Woot! It works!

  37. 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

  38. 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

  39. 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.

  40. Walid says:

    whhhooooo

    you rock

  41. Ido says:

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

    You just made my day..

    Thanks alot!!

  42. 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!
    :)

  43. pritam says:

    It worked men…Thanks for the help

  44. 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…)

  45. 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.

  46. Kelvin says:

    Works like a charm.

    Thanks loads

  47. 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?

  48. 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

  49. 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

  50. 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.

  51. ElMehdi says:

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

    Regards,
    ElMehdi

  52. Roman says:

    Hi,

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

    Cheers,
    Roman

  53. 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

  54. david says:

    thanks, you saved my bacon!!

  55. 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 0x17 (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.

  56. 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)

  57. 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.

  58. 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!

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>