Can a corrupt VHD or VHDX file be recovered or fixed by any manual way? More often than now, the answer to this would be a likely "NO." Hyper-V itself already attempts at performing the auto-repair process if any sort of corruption gets detected in this VHD and VHDX files. But, this does not become possible always. The virtual hard disk drive files are being made of hard-drive footers, which hold the information about that disk, like size as well as geometry etc, along with data blocks. If these disks are dynamic in nature, then there are dynamic virtual hard-disk headers.
Methods for VHDX & VHD Recovery
Occasionally, users come across corruption issues and need to know how to do VHDX and VHD recovery for fixing virtual hard disks issues in which they have been facing this corruption. An easy way out is to run some good recovery tool inside this virtual machine. For economical manual ways though, the process could be long, and for that, users need to know the structure of these virtual hard disks.
• Footer: This has information like disk size, disk creator, disk geometry, etc. Fixed-sized VHDs only have 1 copy of footer but dynamic/differencing ones make 2nd copy too of this footer at top of the VHD.
• Header: This has information about the block allocation table location and the parameters of the structure of this block allocation table along with the info for differencing disks for pointing to proper data location on parent VHD.
• Block Allocation Table: This gets used by dynamic/differencing VHDs for mapping requests for VHD offsets to actual locations on physical hard drive. As per the VHD size, this ranges in size from a few KB to some MB.
• Data-Blocks: This is VHD’s bulk and this happens to be the raw data that virtual machines write to virtual drives.
Corruption Implications on Above Areas & Possible Rectification Actions
In case of fixed-sized virtual drives (or dynamic/differencing ones with corrupted footer & mirror) you get error stating that the VHD is corrupt whenever you start the virtual system (or while editing VHD). There is no such definite method available in this type of issue. Only option resting with you is to restore from updated backup (if you have been backing up) else this is also futile. Footer size is around 511 bytes only chances of this particular type of corruption are pretty meager.
Dynamic VHD header makes use of CRC checksum same as that to hard disk footer. Because of the absence of mirror, this segment’s VHD corruption gives the error from Virtual PC/Virtual Server/Hyper-V stating about virtual hard disk getting corrupt. Again, there is no such foolproof way for recovering out of this particular type of corruption, but you can always try restoring from some updated backup; and same like footer, this type of corruption is less likely to happen owing to the fact of small size up to 1KB only.
For Block Allocation Table
No checksum on this. If this VHD segment was were to get corrupt, users see file-system error inside virtual machines as it will be directed to wrong VHD segment for reading data. There is no such known way with which one can fix this type of corruption problem.
For Data Blocks
Best method for handling this type of corruption issue is to treat the VHD same like physical hard drive that got corrupted and then boot your virtual machine and then run data/disk recovery solutions inside virtual machines.
Most Commonly Encountered Corruption Causes
• Owing to faulty/failing physical storage
• Because of transferring the files over the faulty/failing networks
Backups are important rather mandatory to avert the loss
In a Nutshell
• If any of the Virtual systems/ Virtual Servers/Hyper-V is reporting that your virtual hard disk has got corrupted, then it is probable that one of the headers or footers sections has got corrupt. In this one can do precisely nothing
• If virtual machine is starting fine but reporting error during the access of the disk then you can run recovery software inside those virtual machines