DiscUtils icon indicating copy to clipboard operation
DiscUtils copied to clipboard

Partitions formatted in RAW when pumping Streams from VHDX to Physical Disk

Open andrea92010 opened this issue 7 years ago • 2 comments

Hello, I'm trying to re-image a VHDX to a physical disk but with no success. The problem is that , when opening partition stream from the source vhdx and then pumping it into the destination partition inside the physical disk , I obtain a RAW partition (as stated from Diskpart and Windows Disk Management). This is very strange as, if I open the source sparse stream with a NTFS Filesystem, the files are listed correctly.

Hope that someone can help me. Thanks in advance.

SparseStream sourceStream = SparseStream.FromStream(SourcePartition.Open(), Ownership.None); SparseStream partStream = SparseStream.FromStream(DestCurrPartition.Open(), Ownership.None);

partStream.Position = 0; sourceStream.Position = 0;

var isSrcNTFS = NtfsFileSystem.Detect(sourceStream); // The source stream is correctly read as NTFS !!!!

StreamPump pump = new StreamPump() { InputStream = sourceStream, OutputStream = partStream, };

pump.Run();

andrea92010 avatar Sep 04 '18 09:09 andrea92010

Have you tried to open the destination stream with a NTFS Filesystem after running the StreamPump? Does NtfsFileSystem.Detect(partStream) give the correct result?

zivillian avatar Sep 04 '18 13:09 zivillian

Yes, the destination stream is NTFS as well. But if I "reload" the disk by opening a new handle on it and then opening the same partition stream, the instruction: using (NtfsFileSystem ntfs = new NtfsFileSystem(partition.Open())

gives me error as there is a corrupt record.

The strange thing is that, if I pump the stream above into another VHDX (by creating it with Vhdx.Disk.InitializeDynamic) , the created VHDX mounts perfectly and show NTFS partitions!!!

I suppose that partitions inside VHDX are being saved as RAW (that is a type of virtual disk as well), but I don't know how can i read only the "ntfsStream" without doing a file-by-file copy, that takes much longer than using a stream pump. Is there a way to access just this kind of stream?

PS: I was thinking about using the method "VirtualDisk.OpenDisk" but everytime I get "Unable to parse path error" , that is very strange. Did you have this problem as well?

andrea92010 avatar Sep 05 '18 09:09 andrea92010