Restore a VM using the {vm}-flat.vmdk file

missing vmdk file error

A couple days ago I was asked the question “An admin deleted the vmdk file associated with a VM, there are no snapshots or backups of the VM . Can we restore this VM somehow?“. I believe in backups, I like to have my VM’s backed up so that I can depend on them for events just like this very issue. At first I was stumped, until the {vm-name}.flat.vmdk was mentioned. That’s when I remembered a method to recover a VM using the vm-flat.vmdk file that I had actually done 2-3 years ago.

Example preparation

For this example I’ve created a Server 2012 virtual machine (called Win2012) and placed a text file on the desktop called “Important Info”. I then deleted all the files associated with that VM with the exception of the Win2012-flat.vmdk file, as seen in the image at top.

VM before deleting VMDK file

After the files had been deleted I tried to power up the VM knowing it would not and received this error.
missing vmdk file error

Ok, now on to how to restore a VM with a missing .VMDK file.

How to Recover a VM using a vm-flat.vmdk file

  1. I created a new VM called Recovery with the same specs as my Win2012 server (2vCPU, 4GB RAM, 40GB HHD).
  2. Enable SSH on the host and logged in via PuTTy (or WinSCP) and verified the contents of Win2012 folder:
    cd /vmfs/volumes/vmNFS02/Win2012/

    win2012 folder contents

  3. Then navigate to the Recovery VM folder.
    cd ../Recovery/
  4. Rename the original Recovery-flat.vmdk file to Recovery-flat.vmdk.bak
    mv Recovery-flat.vmdk Recovery-flat.vmdk.bak

    copy recovery-flat.vmdk

  5. Now just copy the Win2012-flat.vmdk file from the Win2012 folder over to the Recovery folder (Note: This step could take several minutes):
    cp /vmfs/volumes/vmNFS02/Win2012/Win2012-flat.vmdk Recovery-flat.vmdk

    copy flat vmdk to recovery folder

  6. Finally, power up the new Recovery VM and your old VM (Win2012) should be back online good as new!
    after restore
  7. You can also go back and delete the Recovery-flat.vmdk.bak file as it won’t be needed.

So even though restoring a VM from a -flat.vmdk file is pretty easy it isn’t my recommended method, you’re far better protected with good, reliable backups, then on hoping that the -flat.vmdk file is still laying around somewhere.

Similar Posts

  • VMware vCenter Server 5.5b released

    vmware vcenter 5.5b released

    VMware hasn’t let the holidays get in their way and has released vCenter Server 5.5b (Build 1476387) along with vCenter Server Appliance 5.5.0b (Build 1476389). The update includes a number of fixes.

    Resolved Issues in 5.5.0b

    Upgrade and Installation

    • Upgrading the vSphere Web Client to vSphere 5.5 fails with an error
      Attempts to upgrade the vSphere Web Client to vSphere 5.5 fails when they are installed in a custom, non-default location. An error message similar to the following is displayed:

      Error 29107. The service or solution user already registered...

    Read More “VMware vCenter Server 5.5b released”

  • VMware VCP exam coupons, save 50%!

    VMware

    Current VCPs save 25% off any VCP exam

    All current VMware Certified Professionals can save 25% on exams taken before January 1st, 2015 on the following VCP exams:

    VMware Certified Professional 5 – Data Center Virtualization

    • Exam Code: VCP550
    • Exam Code: VCP510

    VMware Certified Professional 5 – Desktop

    • Exam code: VCP510-DT
    • Exam code: VCPD510

    VMware Certified Professional – Cloud

    • Exam Code: VCPC550
    • Exam Code: VCPC510
    • Exam Code: VCPVCD510

    VMware Certified Professional – Network Virtualization

    • Exam Code: VCPN610

    Read More “VMware VCP exam coupons, save 50%!”

  • My VMware View Windows 7 Optimization Guide

    These are the few steps I do when creating a new "Golden" image. Luckily I don’t have to do these steps all the time as I’ll create the "Golden" image when there is a new upgrade such as when we went from View 4.6 to View 5.0.1. I like to have a new fresh machine using new virtual hardware from the start. You could certainly just upgrade the virtual hardware on the "Golden" image, I just prefer to start clean.

    At any rate, here’s my list. Hopefully someone might find it somewhat useful and maybe even others can improve upon it.

    Preparing a new virtual machine

    1. Create New Virtual Machine – FILE > NEW > VIRTUAL MACHINE (CTRL+N)
    2. Under Configuration select CUSTOM.
    3. Select a Name, Folder, Host, Cluster, and Storage.
    4. Under Guest Operating System select Windows and then Windows 7 32bit under the Version drop down.
    5. Select which Network (VLAN) and under Adapter select VMXNET 3.
    6. Configure disk size to 30GB THIN provisioned.

    Read More “My VMware View Windows 7 Optimization Guide”

  • Thank you VMware Community!

    VMware vExpert 2014

    So far, 2014 has been a very rewarding year for a number of reasons, two of which has happened in just a week or two span. First, Eric Siebert (@ericsiebert) announced on March 27th, this years results of the 2014 Top VMware & Virtualization Blog voting. My first year entered into voting and made it to 71st place! A huge thanks goes out to not only Eric but just as much so to everyone who voted for me!

    To top it off, yesterday VMware announced 2014’s first quarter VMware vExpert list. While vExpert isn’t a technical certification or even a general measure of VMware expertise. The VMware judges selected people who were engaged with their community and who had developed a substantial personal platform of influence in those communities. There were a lot of very smart, very accomplished people, even VCDXs, that weren’t named as vExpert this year. VMware awarded this title to 754 people this year and on that list of many impressive names you’ll find yours truly, Michael Tabor!

    I’m both honored and humbled by both lists. It’s a great feeling to be recognized by not only my peers through the voting in the Top vBlog but also by VMware themselves through the vExpert title.

    So again THANK YOU very much to the entire VMware community, a spectacular community indeed, and congratulations to everyone else that made the Top vBlog and vExpert lists!

  • VMware View client now availabe for Android!

    VMware has announced that they have released a View Client for Android tablets available on the Android Market now. Here are just a few of the features found on the new client.

    • A new look and feel – The View Client for Android features the NEW blue look and feel of the VMware View clients!
    • Multiple broker support – If you have more than one VMware View broker in your organization, you can can easily access your desktop from all of them via the Android client
    • Desktop Shortcuts – Quickly connect with as many as four recent desktop via shortcuts
    • Virtual trackpad – Control your desktop on a granular level just like you would control the mouse on a laptop
    • Custom keyboard toolbar – Super easy access to all of the special keys not found on the Android default keynboard
    • Honeycomb 3.x support – Made from the ground up for the new generation of Android tablets
    • Custom gestures – Invoke keyboard, scrolling, etc are as easy as ever and simple to use
    • VMware View Security Server support (best experience) – No need to have VPN when you use VMware View Security Server
    • Background tasking – Switch between apps on your tablet and come right back

Leave a Reply

Your email address will not be published. Required fields are marked *

34 Comments

  1. Hi,

    Thanks for the above post :)

    I’m try your post in my home lab but I’m facing the below
    issue . can you please help me to understand the concept .

    I have created a new VM called win7 then logged into the ESXi 5.0 via SSH (putty ) I can view the win7-flat.vmdk
    file but if I delete the win7.vmdk file I can’t see the win7-flat.vmdk . because
    of this I’m not able to perform your post in my lab can you please help me understand
    the concept please and please guide me if I’m wrong

    1. viswa,

      How are you deleting the .VMDK file? If
      removing the VM from disk it will in fact remove all files and folder
      associated with the VM. If you’re browsing the VM folder on the
      datastore and delete the .VMDK file then the {vm}-flat.vmdk file should
      still exist.

      1. Hi Michael,

        Thanks for your help :)

        How are you deleting the .VMDK file?
        Ans : I’m browsing the VM folder in data store and deleted the
        win7.vmdk file . after that i’ve checked ssh to ESXi via putty i’m not able to view the both Vmdk and flat.vmdk files

      2. viswa,

        Sounds like you’re deleting it from the GUI datastore browser. I deleted the file from SSH. Not sure if that might be the issue or not, but i will try it when I get home this evening on my home lab as well.

        If you want to test now you could spin up a new test VM, SSH to the VM folder and delete everything but the {vm}-flat.vmdk file and try the rest of the steps.

  2. Hi i have this problem in real VM , i do these note but my machine isn’t work.
    i work with gui datastore browser.plz help me :(

  3. Thank you very must you saved me, after the material virtual update 9 to 10, the DIsk 1 size take 0 MB (usual 50 GB)
    In a friday (newer do a action on prod a friday ! -but the deadline – grrrrr)

    Imagine I give a virtual Beer ;-) sluurps :)

    From France.

  4. This worked like a charm! Thanks a million! This was a life saver. I was able to recover my Lync 2013 Server with no issues using these instructions. Straight forward and clear.

  5. Hi Mike, do you have an article I can use to get my Datastore (from Synology iSCSI Target) to show up on my VMware host again? I am able to connected successfully and see it mounted but I no longer see the Datastore from Synology showing up on my ESXi Hosts. Thanks!

    1. Hector,

      I don’t have an article for mounting iSCSI targets from Synology to VMware but wouldn’t mind creating one. If you’ve already had this configured at one time then it makes me wonder what has changed since? Also have you tried to do a storage rescan?

      -Michael

  6. hi mike, iam download vm files from one datastore to another data store, I notice that i click download from datastore on my local drive, file is downloading but file name appears on my local drive is myvm-flat.vmdk, why the flat added in it? how can i send you private message or skype? i want to share my screen shots with you

  7. Thank you, thank you, thank you
    You saved my server, did not have any current backups because it was temporary, but SAP consultants never released it.
    Great job and article

  8. How do you find the location of the VM to type it in the “cd /vmfs/volumes/vmNFS02/Win2012” command?

    I am pretty new at this and somehow my vm server had a “bootstrap device not found” error, things got complicated from there — I tried recreating the VM and using the disks of the bad VM, but that gave me another error (bootmgr not found) and even then after using chkdsk tools it went worse.

    I do have the flat.vmdk file for the original VM but nothing else – it seems it is the right size.

    I am not sure how to find the location of that to type in the above command. PLEASE, help!

    Thanks a lot.

  9. Ref: Hi mike, Im download vm files from one datastore to another data store, I notice that i click download from datastore on my local drive, file is downloading but file name appears on my local drive is (myvm-flat.vmdk) this is a backup file from in esxi virtual harddisk

    Another way to save te info when we get a -flat.vmdk file, is with power iso, this app can open te file .vmdk as it was a .rar file and extract the needed files and folders.

    Thanks to you and and other soulds that saved my day and night and 3years of works!