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!

0 0 votes
Article Rating
Subscribe
Notify of
guest
57 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Michael Stone

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!

Nick Pham

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.

Chad

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

david

thanks, you saved my bacon!!

Roman

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

Roman

Hi,

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

Cheers,
Roman

ElMehdi

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

Regards,
ElMehdi

Kody

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.

HND

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

PiNG

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

Maurice

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 »

Kelvin

Works like a charm.

Thanks loads

Maurice

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 »

Maurice

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 »

pritam

It worked men…Thanks for the help

Tedson

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!
🙂

Ido

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

You just made my day..

Thanks alot!!

Walid

whhhooooo

you rock

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.

Brett

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 »

Kat

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

Stephane

Woot! It works!

Jano

Thank you for the information !

Semion

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

getupaaaah

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.

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

Mandy

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

Thorn

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.

waxs

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

Thanks and your rock!

Millman

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!

Ryan

Worked perfectly thank you!

adastra

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

Nocte

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

bizarro stormy

It worked! Thank you very very much.

Will

Saved me a call to Vmware tech support… Cheers

Steve Reynolds

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

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

Georges

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

timhoa

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

chabi

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

Cesar G

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,

Will Richardson

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!

ravi prakash

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 »

userxp

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 »

VG

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

Isuru Manikkage

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

Isuru Manikkage

Anonymous

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 »

Thankful User :)

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!! 🙂

Jose

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

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?

Mark Hill

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*

Support

Great, thanks a million !

57
0
Would love your thoughts, please comment.x
()
x