Tuesday, May 14, 2013

Corrupted VHD files

Corrupt VHD files...  We utilize PVS and when we were attempting to update the target device software utilizing Hyper-V we got several error messages saying the VHD is corrupted.  The actual root of the issue is that PVS makes 16MB block size VHD files (thanks SAMAN!) and Windows 2008 only reads VHD files that are 512KB or 2MB block sized files.

Attempting to mount the VHD file via disk management fails as well.  The only utility that would mount the VHD file that was generating the error messages at the end of this post is the Citrix CVHDMount utility available via PVS (C:\Program Files\Citrix\Provisioning Services\CVHDMount.exe)

Since our Hyper-V server was separate from the PVS server, we needed to install the drivers to allow CVHDMount.exe to work.  In order to do this you need to install the drivers in this folder:
C:\Program Files\Citrix\Provisioning Services\drivers

You can right-click "Install" on the cfsdep2.inf file.

For the other driver you need to open Device Manager, go through "Add new hardware...", "Add legacy hardware" and then browse to the drivers folder and add the cvhdbusp6.inf.

Now we would mount the disk as a drive letter using this command line:

C:\Users\trententtye>"C:\Program Files\Citrix\Provisioning Services\CVhdMount.exe" -p 1 "\\wsctxapp824\d$\XenApp65Pn02.2.vhd"
Opening \\?\root#scsiadapter#0000#{c97efdbd-972c-4fe8-8279-9ce6c19fa260}
Bus interface opened.
Plugin device with SerialNumber: 1
filename: \Global??\UNC\wsctxapp824\d$\XenApp65Pn02.2.vhd

At this point you need to set the disk to "Offline" in Disk Management.


From here we can now add the disk as a physical disk to Hyper-V.


And we can now do the Target Device Update.

"---------------------------
Virtual Disk Manager
---------------------------
The file or directory is corrupted and unreadable. 
---------------------------
OK   
---------------------------
"

"[Window Title]
Settings

[Main Instruction]
Error Applying Hard Drive Changes

[Content]
Failed to modify device 'Microsoft Virtual Hard Disk'.

Cannot open attachment 'D:\XenApp65Pn02.2.vhd'. Error: 'The file or directory is corrupted and unreadable.'

Cannot get information for attachment 'D:\XenApp65Pn02.2.vhd'

Cannot open attachment 'D:\XenApp65Pn02.2.vhd'. Error: 'The file or directory is corrupted and unreadable.'

[Expanded Information]
'NewMachine' failed to modify device 'Microsoft Virtual Hard Disk'. (Virtual machine ID D8D73511-6D6B-4604-A09B-BA4F5CD35206)

'NewMachine': Cannot open attachment 'D:\XenApp65Pn02.2.vhd'. Error: 'The file or directory is corrupted and unreadable.' (0x80070570). (Virtual machine ID D8D73511-6D6B-4604-A09B-BA4F5CD35206)

'NewMachine': Cannot get information for attachment 'D:\XenApp65Pn02.2.vhd'. (Virtual machine ID D8D73511-6D6B-4604-A09B-BA4F5CD35206)

'NewMachine': Cannot open attachment 'D:\XenApp65Pn02.2.vhd'. Error: 'The file or directory is corrupted and unreadable.' (0x80070570). (Virtual machine ID D8D73511-6D6B-4604-A09B-BA4F5CD35206)

[V] See details  [Close]"

asdf

3 comments:

|Atum| said...

For what its worth, I've experienced this and it just came back to me today when I tried to mount a vhd. My VHD was created with the PVS imaging wizard originally which may have been the cause (not sure). At any rate, the workaround I used was to use "VhdResizer" to copy the VHD block by block. Hope this helps.

Trentent said...

VHD Resizer fails when the block size is 16MB. When I used it to "clone" the VHD to another the "clone" was throughly corrupt.

Anonymous said...

Thank you so much! I thought there was something wrong with my vDisk until it happened to a 2nd one. Then I was confident it had to be some sort of settings that Hyper-V can't read.