Corrupt Vhd — Repair
He ran:
By 5:00 AM, the transit authority’s schedule database was back online. The city’s morning buses rolled out on time, never knowing that their entire route database had been hanging by a thread of manually repaired block tables.
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: . repair corrupt vhd
Next, he tried -> Edit Disk . The wizard froze at 12% while attempting to compact the drive. No dice.
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. He ran: By 5:00 AM, the transit authority’s
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. He used OSFMount from PassMark
chkdsk Y: /f /r /x CHKDSK ran for 90 minutes. It reported fixing three orphaned files and two bad clusters in the MFT (Master File Table). But when he unmounted and tried to attach the VHD again in Hyper-V? Same corruption error. CHKDSK fixed the filesystem inside the VHD, but not the container itself.