I recently had a network issue causing an iSCSI LUN containing my Server 2012 R2 Hyper-V VHDX files to drop for a split second. Unfortunately for me, this was enough to cause the entire data drive VHDX file for my file server to become corrupt. The VM wouldn't even start, giving the error: "The application encountered an error while attempting to change the state of 'VMNAME'. 'VMNAME' failed to change state." Additionally, if I tried to inspect the disk within Hyper-V Manager, it gave the error: "An error occurred when attempting to retrieve the virtual hard disk 'F:\Hyper-V\Virtual Hard Disks\VMNAME\disk-1.vhdx' on server HVSERVER.corp.local. Failed to get the disk information. An unexpected error occurred: The file or directory is corrupted and unreadable. (0x80070570)."
Everything I came across online in my feverish searching seemed to apply only to VHD files and older versions of Hyper-V. Nothing would read it. I then came across this article which dashed all of my hopes of recovering it: http://blogs.msdn.com/b/virtual_pc_guy/archive/2009/01/07/how-do-i-fix-a-corrupted-virtual-hard-disk.aspx. Towards the bottom of it reads this line: "If Virtual PC / Virtual Server / Hyper-V report that the virtual hard disk is corrupt - then one of the header / footer sections has been corrupted - and there is nothing that you can do."
Well that's it. Game over. I guess I have to go to tape.
But in my desperation, I recalled reading somewhere to make the VHDX file as read only which then might allow you to mount it. So I went into the file properties, checked the read only box, clicked apply, and crossed my fingers. I double clicked the VHDX file and held my breath... TADA!!! It mounted to the Hyper-V host! All of my data was there and accessible. From there I created a new drive on the VM and robocopied it over.
I don't even remember where I saw to make it read only. It was likely a page that talked about something else and didn't seem relevant enough to my issue at the time, and so I moved on. But I hope this saves someone out there some time and frustration in case this happens to them.
Labels: hyper-v, iscsi, Microsoft, vhdx