This article was first published as a blog post. It is offered here for community extension. Do you know of another symptom, cause, fix or tool that is relevant? Please add what you have; it is the wiki way.
Symptoms and error messages for corrupted Hyper-V VHD files are numerous, from the VM refusing to start, to failures to attach the VHD with messages like
"Failed to open attachment 'C:\ directory \MyVHD.vhd'. Error: 'The file or directory is corrupted and unreadable.'”
There are many possible causes why your VHD may become corrupted. It is not necessary to figure out the exact cause if you need it back fast: just
restore the VHD from your latest backup, or as
Ben Armstrong puts it in his blogpost “Run data recovery tools inside the virtual machine."” As with all things in IT “fast” is a relative term – restoring a 500 GB disk from backup can take hours. Plan accordingly.
If you are going to take the time to investigate the cause, or do not have a backup, then you must “get forensic”.
No mater what the VHD type, most common causes of data corruption in the VHD (whether fixed or dynamic) are from:
If you can trace back the chain of events leading to the corruption, you will usually find a failure either by disconnecting storage while the virtual drive was being created or moved over the network Note that switching the disk-type from one to the other
or expanding the disk may cause the problem, and,
for some people, it has solved the problem. Sometimes this failure is not hardware, but caused by 3rd party encryption and
anti-virus programs that have been installed on the host.
This Core Team blog post shows one way to begin your analysis.
Fixes to try: