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!

Leave a Reply

61 Comments on "Howto: Recreate VMDK files"

Notify of
avatar
Sort by:   newest | oldest | most voted
Biatch
Guest

Thanks for sharing your thoughts on the devil wears prada.

Regards

Col
Guest

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

Scott@EMC
Guest
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… Read more »
Support
Guest

Great, thanks a million !

Mark Hill
Guest

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*

Jose
Guest

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
Guest

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?

Thankful User :)
Guest

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

Isuru Manikkage
Guest

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

Isuru Manikkage

Anonymous
Guest
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… Read more »
VG
Guest

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

userxp
Guest
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… Read more »
ravi prakash
Guest
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”… Read more »
Will Richardson
Guest

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!

Mitry
Guest

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?  

Cesar G
Guest

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,

chabi
Guest

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

timhoa
Guest

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

Ton
Guest

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 !
  

Ton
Guest

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

Georges
Guest

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

Steve Reynolds
Guest
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… Read more »
Jason Henderson
Guest

Whew! Steve, your post worked perfectly for me. Thank you everyone!

Will
Guest

Saved me a call to Vmware tech support… Cheers

bizarro stormy
Guest

It worked! Thank you very very much.

Nocte
Guest

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

adastra
Guest

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

Ryan
Guest

Worked perfectly thank you!

Millman
Guest

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!

waxs
Guest

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

Thanks and your rock!

Thorn
Guest

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.

Salvatore
Guest

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.

Mandy
Guest

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

Mandy
Guest

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?

getupaaaah
Guest

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.

Semion
Guest

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

Jano
Guest

Thank you for the information !

Stephane
Guest

Woot! It works!

Kat
Guest

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

Brett
Guest
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… Read more »
Zack
Guest

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.

Walid
Guest

whhhooooo

you rock

Ido
Guest

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

You just made my day..

Thanks alot!!

Tedson
Guest

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

pritam
Guest

It worked men…Thanks for the help

Maurice
Guest
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… Read more »
Maurice
Guest
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… Read more »
Kelvin
Guest

Works like a charm.

Thanks loads

Maurice
Guest
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… Read more »
PiNG
Guest

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

HND
Guest

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

Kody
Guest

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.

wpDiscuz