ThisCalculator

Everyday

VHD File Is Corrupt and Unreadable? Fix It Now

Updated · Standard formula, shown below

VHD File Is Corrupt and Unreadable? Fix It Now

Yes, a VHD file can become corrupt and unreadable, but in most cases the data inside is still recoverable. This article explains the common causes of VHD corruption and walks you through the practical steps to repair the file or recover its contents.

What Is a VHD File?

A VHD (Virtual Hard Disk) file is a disk image format that stores the complete contents of a hard drive, including the operating system, applications, and files. It was introduced by Microsoft for use with virtualization products like Hyper-V and Virtual PC, and it remains widely used today. The format has a newer variant called VHDX, which supports larger disks and is more resilient to corruption, but the repair concepts are similar.

VHD files come in three types:

  • Fixed-size VHD: The file is allocated its full size at creation, which can be large but offers predictable performance.
  • Dynamic VHD: The file grows as data is added, up to the maximum size specified.
  • Differencing VHD: A child disk that stores changes relative to a parent disk, used for snapshots and test environments.

Because a VHD is a single file that acts like a whole disk, corruption in that file can affect the entire virtual machine, making it unable to boot or mount.

Why Do VHD Files Become Corrupt?

Corruption can happen for several reasons, and understanding the cause helps you choose the right repair approach. Common triggers include:

  • Improper shutdown: If the host machine loses power or the virtual machine is forcibly stopped, the VHD may not be flushed to disk properly.
  • Disk full: When the physical disk hosting the VHD runs out of space, writes can fail and leave the file in an inconsistent state.
  • Hardware issues: Failing hard drives, bad sectors, or faulty RAM can corrupt any file, including VHDs.
  • Software bugs: Bugs in the virtualization software or the guest OS’s disk drivers can cause corruption.
  • Malware or antivirus interference: Some security software may lock or modify VHD files unexpectedly.

Often the error message you see, such as “The VHD file is corrupt and unreadable,” appears when you try to attach the disk in Disk Management or when the virtual machine fails to start.

How to Repair a Corrupt VHD File

Before attempting repairs, make a copy of the VHD file if you have enough disk space. This ensures you can try different methods without risking further damage to the original.

Here are the main repair approaches, in order of least to most invasive:

1. Use Hyper-V’s Built-in Repair Tool

Windows Hyper-V includes a command-line tool called repair-vhd that attempts to fix a corrupted VHD by rebuilding its footer. To use it:

  1. Open PowerShell as an administrator.
  2. Run the command: Repair-VHD -Path C:\path\to\your.vhd
  3. If the tool succeeds, it will report that the repair was completed.

This tool works best for VHDs with a damaged footer or header, but it may not recover data if the file is severely corrupted.

2. Mount the VHD in a New Virtual Machine

Sometimes the VHD is fine, but the virtual machine configuration is broken. Create a new VM and attach the VHD as an existing disk. This often bypasses the corruption error if the issue is only with the VM settings.

3. Use DiskPart to Attach the VHD

DiskPart is a Windows utility that can attach VHDs directly. Open Command Prompt as administrator and run:

  1. diskpart
  2. select vdisk file="C:\path\to\your.vhd"
  3. attach vdisk

If the attachment succeeds, the VHD appears as a new disk in Disk Management, and you can copy files from it. If it fails, the corruption is more serious.

4. Use a Third-Party Recovery Tool

If the built-in tools fail, commercial data recovery software can often extract files from a corrupt VHD. These tools scan the raw data and rebuild the file system structure. Some popular options include R-Studio, EaseUS Data Recovery Wizard, and DiskInternals VHD Recovery. They are not free, but they are often the only way to recover data from a severely damaged VHD.

5. Check the Underlying Physical Disk

If the VHD is on a failing hard drive, the corruption may be due to bad sectors. Run chkdsk on the physical drive that contains the VHD to identify and isolate bad sectors. This won’t fix the VHD itself, but it can prevent further damage.

How to Prevent VHD Corruption

Prevention is far easier than repair. Follow these best practices to minimize the risk of VHD corruption:

  • Always shut down the virtual machine gracefully before stopping the host.
  • Ensure the host has enough free disk space for the VHD to grow.
  • Use VHDX format when possible; it has built-in corruption protection.
  • Regularly back up your VHD files to a separate physical drive.
  • Monitor the health of your physical hard drives using SMART tools.

Alternatives to Repairing a VHD

If repair is not possible, you can sometimes recover data by other means:

  • Extract files from a shadow copy: If you have Volume Shadow Copy enabled on the host, you may be able to access previous versions of the VHD file.
  • Use a Linux live CD: Boot a Linux distribution and mount the VHD using the qemu-nbd tool or the kernel’s built-in NBD driver. This can sometimes read a VHD that Windows refuses to mount.
  • Convert the VHD to a raw image: Tools like qemu-img can convert a VHD to a raw .img file, which might be mountable even if the VHD header is damaged.

Frequently Asked Questions

Can I recover files from a corrupt VHD without any tools?

If the VHD’s file system is intact but the header is corrupt, you might be able to attach it using DiskPart or mount it in a new VM. If those fail, you’ll need third-party recovery software.

Is a VHDX more reliable than VHD?

Yes, VHDX includes features like larger block sizes and a log that helps protect against corruption during power failures. It also supports up to 64 TB, compared to VHD’s 2 TB limit.

What does “The virtual machine could not be started because the hypervisor is not running” mean?

This error is unrelated to VHD corruption; it means Hyper-V is not enabled or the host doesn’t support virtualization. Enable Hyper-V in Windows Features or check BIOS settings.

Can I open a VHD file in Windows without Hyper-V?

Yes, you can attach a VHD in Disk Management (right-click > Attach VHD) or use DiskPart. This works on Windows 7 and later, even without Hyper-V installed.

Will chkdsk repair a corrupt VHD?

No, chkdsk works on physical disks, not on VHD files. Running it on the host drive won’t fix the VHD itself, but it can help if the corruption is due to bad sectors on the physical disk.

When to Give Up and Start Over

If you’ve tried all the repair methods and data recovery tools, and the VHD still won’t mount, it may be beyond repair. At that point, the best option is to restore from your last backup. If you don’t have a backup, you may have to recreate the virtual machine and reinstall the OS and applications. This is why regular backups are essential for any virtualized environment.

Remember, the earlier you attempt repair, the higher the chance of success. Don’t keep using the VHD after you notice corruption, as further writes can overwrite data that might still be recoverable.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.