Issue with open/read contents of VHD Disk which created from Disc2vhd Tool

Dec 14, 2009 at 3:17 PM

Hi All,

I'm attempting to open/read the contents of  a VHD disk, created with Disk2Vhd , but I get this message "Corrupt record".

I can successfully mount this VHD disk in Gizmo and view it's contents.

I use the following lines to open the VHD file :

Stream vhdStream = File.OpenRead(@"D:\Disk2vhd\LEOVISTA1.VHD");
NtfsFileSystem fs1 = new NtfsFileSystem(vhdStream);

After further debugging, it appears that the following line in NtfsFileSystem generates the error :

File mftFile = new File(_context, MasterFileTable.GetBootstrapRecord(stream, _context.BiosParameterBlock));

Here is another observation
If I generate a VHD using Disk2VHD and mount it in Gizmo, I am first prompted to format the VHD. After a successful format via the Gizmo utility, I can then add new files to the mounted drive and then subsequently also successfully use the DiscUtils API to read the contents of the VHD.

Regards:

Rajesh

<input id="gwProxy" type="hidden" /><input id="jsProxy" onclick="jsCall();" type="hidden" />

Coordinator
Dec 14, 2009 at 5:39 PM

Hi Rajesh,

I think there are a couple of things going on here:

1. You created a disk using Disk2VHD, that gizmo couldn't read - this suggests a bug in Gizmo or Disk2VHD

2. Gizmo doesn't create VHD files.  A Gizmo *.gdrive is an image of a single partition of a hard disk, not a proper VHD file

What your code actually does is just opens a stream, and then starts to interpret it as an NTFS file system.  This is probably the right thing to do for Gizmo drives, but not how you open a VHD.

To open a VHD you need to use the DiscUtils.Vhd.Disk class, you then need to use DiscUtils.VolumeManager to interpret the partition table - then you need to open a single partition as an NTFS file system.

Cheers,

Ken

Dec 15, 2009 at 9:49 AM

Thanks Ken for this quick reply with valuable information.

Regards:

Rajesh