How to Repair Corrupt and Damaged VHD File
As we know that the VHD stands for Virtual Hard Disk and it stores very crucial data. In any situation, your .vhd file gets corrupted and inaccessible. Then you have two options, either repair VHD file by PowerShell command or repair damaged VHD file by creating the virtual server. Let’s discuss both methods in detail.
Method 1:
PowerShell empowers the user to automate the process. But the commands are hectic to use if you are not familiar with formats of commands. So I recommend you to first take backup and then execute the PowerShell command to repair corrupt VHD file. Run the command on PowerShell CMD:
- Choose what VHD we want to mount $VHDName = “V:\serverx.vhd“
- Get the MSVM_ImageManagementService
- $VHDService = get-wmiobject -class “Msvm_ImageManagementService” -namespace “root\virtualization” -computername “.”
- Now execute this command to mount vhd file
- $Result = $VHDService.Mount($VHDName)
Method 2:
The user can also repair corrupt VHD file by creating new virtual machine and after that link or add the damaged VHD file to the newly created virtual machine and then compact it. To complete this process performs the steps listed below:
- First, create the new virtual server and attach new hard disk.
- Now click on Setting and add newly created hard disk. After that browse the VHD file in it.
- Here hit on Virtual Disk Wizard and then select the Compact option. There should be Convert it to a Fixed Size Virtual hard Disk check-box checked.
- At the end Save this VHD file by new name. You can also save by original file name.