How To Fix a Corrupted VHDX File

Understand the actions, or rather lack of actions, that can be performed for a corrupted VHD or VHDX file.

Q. Can I manually fix a corrupted VHD/VHDX file?

A. The answer is likely "no." Hyper-V already tries to perform an auto-repair if it detects a corruption in a VHD/VHDX file. However, this is not always possible. A virtual hard disk file is made up of a hard drive footer that contains information about the disk, such as size and geometry, and data blocks. If the disk is dynamic, there is a dynamic virtual hard disk header.

For a dynamic disk there is a mirror copy of the footer at the start of the file. If the footer is corrupt, then the mirror at the start of the file is automatically restored over the footer and used. If the disk is fixed (which means no mirror of the footer at the start of file) or the mirror is also corrupt, there is no way to perform a repair. The only action possible is to restore a backup of the VHD. Note that the hard disk footer for a VHD is very small (sub-1KB), which means a corruption is unlikely to occur. There are no manual steps you can take to solve this type of corruption other than the VHD/VHDX restore.

If data in the data block is corrupt, then run disk repair tools within the virtual machine (such as chkdsk) to try and recover data. This is the same action you would take if there were problems on a physical machine.

Microsoft has a blog article that walks through this in more detail. (The article is rather old, but still valid.) If you are really desperate, you can review the VHDX specification. However, ensuring you have a good backup strategy in-place is the best option.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish