VHD/VHDX file format which is similar to a hard drive is also prone to get corrupted and sometimes unreadable. The difference between VHDX and the physical hard drive is that VHDX is a virtual machine environment. The VHD/VHDX files getting corrupted or unreadable is a common problem and not easy to fix. However, there are many tricks and solutions available for fixing the error. In most cases, files are recovered from the corrupted and damaged file using the methods discussed in this blog.
The corruption can result in huge data loss for the user and it can be permanent also. When the VHD file is damaged or corrupted you will see an error just like below mentioned.
“Failed to open attachment Error: The file or directory is corrupted or unreadable”.
Most common 3 reasons for VHD/VHDX files getting corrupted
- Faulty Hard Disk storage – Due to the manufacturer’s fault or firmware hard disk can get corrupted or damaged.
- Files transferring over the faulty network – There is a greater chance of files getting corrupted when they are transferred over the faulty network. Also if there happens to be a disconnection during the creation or transfer of files in a virtual drive then also it causes errors.
- Errors due to antivirus software – Antivirus sometimes affects everything in the system by scanning and creating barriers.
Similarly, if it interferes in the operations of virtual machines, it causes errors. It’s preferred to exclude virtual machine-related operations from the scanner of antivirus.
Fixing the errors
There are many workarounds through the system to fix these problems. In this blog, we will explain six methods you can save data from corrupted files and repair them.
Fix 1: Create a new virtual machine for repairing VHD/VHDX files
- Create a new Virtual Server then add a new hard disk.
- Locate the Settings option to load a .vhd file.
- Tap on the Virtual Disk > click on the Compact option before clicking on the Next button.
- In the next step check the box and convert it to a fixed size virtual hard disk option. Then move to the next step.
- Now you can save the output VHDX file with a new name.
- After the VHDX file is compacted you can copy and mount it to the original server.
Fix 2: Using Windows Powershell to repair the VHDX file
- Open Windows PowerShell as an admin to get started.
- Enter Mount-VHD-path d:\folder\vdisk.vhdx –Readonly before pressing Enter. Next, Optimize-VHD-path d:\folder\vdisk.vhdx –Modefull> Enter.
- Finally, Dismount-VHD-path d:\folder\vdisk.vhdx > Enter (path d:\folder\vdisk.vhdx is corrupted file’s complete path).
Fix 3: Repair VHD/VHDX by running CHKDSK
- On the Start button type cmd and hit Enter to launch the command prompt.
- Now type diskpart and press Enter to open DiskPart.
- Then type chkdsk D:/f/r/x before pressing Enter button. This will automatically start repairing the VHD/VHDX files by repairing bad sectors on the file.
Fix 4: Delete & Create new VHDX partitions
- Right-click on MyPC and select Manage from the menu.
- Click on Disk Management to find the VHD disk partition. Right-click on the partition and then select Delete Volume.
- Click on the Yes option to confirm the deletion of the file.
- On the unallocated space on VHD right-click and select New Simple Volume.
- To finish the process assign an alphabet to the new drive and your new VHDX partition will be active. You can now save data into the new drive.
Fix 5: Fixing the VHDX files using the inbuilt utility
- Mount the parent partition VHDX in the system.
- Use the CHKDSK option to fix and solve the issue.
- Now check the integrity of the VHDX file using the Hyper-V virtual machine.
- There is now a need to add a VHDX file to the IDE controller. Then select Inspect option.
- To check whether the file is working in the windows 2007, 2008 server, merge any VHD files.
- Download the free VHD tool that includes a repair option. This will undo the expansion of on-base VHDX when different files are merged.
Fix 6: Formatting VHDX to the NTFS file system
If any of the above five solutions don’t work you can use this one to create a new file system to make it accessible.
- Open MyComputer or ThisPC on the virtual machine.
- Find the virtual hard disk and right-click on it to select Format.
- Choose NTFS as the file system for the VHD that needs to get formatted.
- Finally, click Ok to format VHD to NTFS.
VHD/VHDX file which is similar to the physical hard drive is also prone to getting corrupt. In most cases the data is recoverable and the file is reparable but when the damage is a lot it causes permanent data loss. To recover the data, user can use VHD recovery tool to repair corrupt VHD/VHDX files.