Voicertool
Repair Corrupt Vhd Here
He downloaded VHDTool (a small open-source CLI utility). Its job: analyze and fix the VHD footer/header alignment.
The Ghost in the Machine: A VHD Repair
Marcus opened Disk Management (diskmgmt.msc). He clicked Action > Attach VHD . The dialog hung for 45 seconds before spitting out: "Virtual Disk Manager: The virtual disk is corrupted or unreadable." repair corrupt vhd
He navigated to Z:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\ . The .mdf and .ldf files were there. He ran DBCC CHECKDB against a test restore—no allocation errors.
Marcus knew a trick: mount the VHD as a raw disk using a loopback driver. He used OSFMount from PassMark. He mounted the VHD as a read-only raw drive letter Y: . He downloaded VHDTool (a small open-source CLI utility)
He ran:
The sector size was misaligned. The VHD's internal "footer" (the last 512 bytes of the file) was intact—he confirmed that with a hex dump—but the BAT (Block Allocation Table) had a phantom block pointing to a sector that didn't exist. He clicked Action > Attach VHD
The tool had detected that the dynamic VHD header had a checksum mismatch—likely from an unclean Hyper-V host shutdown. VHDTool recalculated the checksum and zeroed out the corrupted BAT entry that pointed to a non-existent sector.
He downloaded VHDTool (a small open-source CLI utility). Its job: analyze and fix the VHD footer/header alignment.
The Ghost in the Machine: A VHD Repair
Marcus opened Disk Management (diskmgmt.msc). He clicked Action > Attach VHD . The dialog hung for 45 seconds before spitting out: "Virtual Disk Manager: The virtual disk is corrupted or unreadable."
He navigated to Z:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\ . The .mdf and .ldf files were there. He ran DBCC CHECKDB against a test restore—no allocation errors.
Marcus knew a trick: mount the VHD as a raw disk using a loopback driver. He used OSFMount from PassMark. He mounted the VHD as a read-only raw drive letter Y: .
He ran:
The sector size was misaligned. The VHD's internal "footer" (the last 512 bytes of the file) was intact—he confirmed that with a hex dump—but the BAT (Block Allocation Table) had a phantom block pointing to a sector that didn't exist.
The tool had detected that the dynamic VHD header had a checksum mismatch—likely from an unclean Hyper-V host shutdown. VHDTool recalculated the checksum and zeroed out the corrupted BAT entry that pointed to a non-existent sector.