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 Recertification Policy

    VMware certified

    Starting today, March 10 2014, new VCP certifications must be re-certified within two years of it’s earned date. Anyone who currently has their VCP certification prior to March 10 2013 has until March 10, 2015 to re-certify.

    The new policy gives you three options to re-certify:

    1. Take the current exam for your existing VCP certification solution track. For example, if you are a VCP3, you could take the current VCP5-Data Center Virtualization (VCP5-DCV) exam.
    2. Earn a new VCP certification in a different solution track. For example, if you are a VCP-Cloud, you could recertify by earning VCP5-Desktop (VCP5-DT) certification.
    3. Advance to the next level by earning a VMware Certified Advanced Professional (VCAP) certification. For example, if you are a VCP5-DCV you could earn VCAP5-DCA certification.

    I can understand why they are doing this but I don’t agree with the changes. As per the announcement if you let your certification expire, “Your certification will be revoked,and you will no longer be entitled to use the certification logo or represent yourself as VMware certified“. Really? You mean everything that was done prior and after taking the exam means nothing?

    Read More “VMware Recertification Policy”

  • VMware ESXi 5 home lab upgrade

    In the past I’ve been using a single server to run my VMware ESXi home lab. it was slow, old, big and loud. I’ve been meaning to upgrade my home lab for a while and just never got around to it, until now! When looking for new hardware I wanted the servers to be as compact as possible, quiet, and low energy usage as possible while still having some horsepower.

    I debated on going the whitebox solution as I build all my own desktops anyway, I also looked at several other solutions such as the HP ML310e server, Shuttle XH61V barebones machine, but ultimately decided to go with two Intel NUC i5’s.

    Intel NUC i5 and 16GB ram

    Intel NUC i5 DC53427HYE Features:

    • Uses very little energy
    • Completely quiet
    • Supports up to 16GB RAM
    • A dual core CPU that scores nearly 3,600 in PassMark benchmarking
    • Includes vPro which allows me to easily run both NUC’s headless
    • Extremely small, nearly 4 1/2″ inch square footprint

    Read More “VMware ESXi 5 home lab upgrade”

  • VMware Workstation 12 Pro Released

    VMware has just released a new version of Workstation in VMware Workstation 12 Pro. Workstation 12 Pro provides full support for Windows 10, including features such as Cortana and universal applications. As well as even larger virtual machines with up to 16 vCPU’s and 64GB of memory. Workstation 12 Pro even supports 4K displays and DirectX 10 and OpenGL 3.3

    You can even seamlessly drag and drop virtual machines between your PC and your internal cloud running vSphere, ESXi or another instance of Workstation. In addition, easily connect to vCloud Air and upload, run, and view virtual machines right from the Workstation 12 Pro interface.

    Read More “VMware Workstation 12 Pro Released”

  • Altaro VM Backup Setup Step-by-Step

    Altaro VM Backup

    Altaro VM Backup is a company who offers a backup solution for small to medium sized businesses and have been around for a while that started out offering backup software for Hyper-V, but has now expanded to VMware as well. Altaro asked if I would be interested in trying for free as part of the vExpert program in my home lab.

    I help out a few small companies here in town so having another backup solution to possibly suggest certainly wouldn’t hurt, so I decided to give it a try and below are my steps to setting it up and thoughts about the software so far.

    Read More “Altaro VM Backup Setup Step-by-Step”

  • My VMware ESXi Home Lab Upgrade

    Although the focus in my career right now is certainly more cloud focused in Amazon Web Services and Azure, I still use my home lab a lot.

    For the last 5+ years my home lab had consisted of using 3x Intel NUC’s (i5 DC53427HYE), a Synology NAS for shared storage and an HP ProCurve switch. This setup served me well for most of those years. It has allowed me to get many of the certifications I have, progress in my career and have fun as well.

    At the start of this year I decided it was time to give the home lab an overhaul. At first I looked at the newest generation of Intel NUC’s but really wasn’t looking forward to dropping over $1,300 on just partial compute (I’d still need to be RAM for each of the 3 NUC’s). I also wanted something that just worked, no more fooling around with network adapter drivers or doing this tweak or that tweak.

    I also no longer needed to be concerned about something that had a tiny footprint. I also questioned if I really needed multiple physical ESXi hosts. My home lab isn’t running anything mission critical and if I really wanted I could always build additional nested VMware ESXi hosts on one powerful machine if I needed.

    So in the end, the below is what I settled on. Replacing all of my compute, most of my networking and adding more storage!

    Read More “My VMware ESXi Home Lab Upgrade”

Leave a Reply to bta Cancel 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!