Opened 8 years ago
Last modified 8 years ago
#15552 new defect
attaching differencing vhd on host makes it unusable on guest
| Reported by: | lfmeloman | Owned by: | |
|---|---|---|---|
| Component: | virtual disk | Version: | VirtualBox 5.0.22 |
| Keywords: | Cc: | ||
| Guest type: | Windows | Host type: | Windows |
Description
When you attach a differencing VHD on Windows host using diskpart or mmc, there's a chance that VBox will no longer understand the format of that VHD. If guest booted, it will see a corrupted filesystem.
I attach my VHD file on Windows 7 host. It's virtual size is 50G and it has one partition formatted to NTFS. I created a dummy VM in VBox GUI to manage snapshots. Currently, the chain consists of 4 image files.
I didn't boot the guest until now. When I did, guest chkdsk spew tons of errors. Then I stopped the guest and attached the VHD on host again. chkdsk showed no errors.
I went further and restored the 'good' backup (there's a backup of all the .vhd and .vbox files I made before the guest boot). Marked the volume as readonly using diskpart and compared the contents of the block device using cygwin. They're indeed different!
Attachments (1)
Change History (4)
by , 8 years ago
comment:2 by , 8 years ago
Was able to create a 5Mb archive with such broken image: https://drive.google.com/file/d/0B40Hp1Tx6I6eRGpmV2dsT1ZsMlk/view?usp=sharing
It contains just one file "bigfile". The leaf image is {b4aabbb3-6e63-4be1-806e-9358d6ff848b}.vhd . When attached to host, its md5sum is a4b477f13e6b4f16b422838591e0f789 . When attached to Windows 2012 guest, the checksum is different every time, probably due to corrupted FS.
What I did:
C:\>
mkdir C:\testvhd
diskpart
DISKPART>
create vdisk file=v:\vm\testvhd2\aatestvhd.vhd type=EXPANDABLE maximum=50000
select vdisk file=v:\vm\testvhd2\aatestvhd.vhd
attach vdisk
convert mbr
create partition primary
format fs=ntfs label="testvhd" quick
assign mount=C:\testvhd
REM create bigfile (write random data at random positions)
detach vdisk
REM add aatestvhd.vhd to the VM
REM create snapshot
select vdisk file=v:\vm\testvhd2\Snapshots\{190fa42d-e3a6-4043-9da5-f0171dc208cc}.vhd
attach vdisk
REM update bigfile (write random data at random positions)
detach vdisk
REM create snapshot
select vdisk file=v:\vm\testvhd2\Snapshots\{1f05a118-d620-4113-834d-ab17a62ecfba}.vhd
attach vdisk
REM update bigfile
detach vdisk
REM create snapshot
select vdisk file=v:\vm\testvhd2\Snapshots\{4c40c3ab-fcfe-4a52-af73-1a6e29c476d4}.vhd
attach vdisk
REM update bigfile
detach vdisk
REM create snapshot
select vdisk file=v:\vm\testvhd2\Snapshots\{b4aabbb3-6e63-4be1-806e-9358d6ff848b}.vhd
attach vdisk
list vol
sel vol 6
att vol set readonly
detach vdisk


The image hierarchy is not broken. I checked that the output of
VBoxManage showhdinfoanddetail vdiskmatches for each vhd file.To compare the contents of the block devices I calculate md5sum of each 1Mb chunk using cygwin and put it into a text file, then compare the text files:
There The image hierarchy is not broken. I checked that the output of
VBoxManage showhdinfoanddetail vdiskmatches for each vhd file.To compare the contents of the block devices I calculate md5sum of each 1Mb chunk using cygwin and put it into a text file, then compare the text files:
After repeaded attach/detach vdisk and guest boots I can tell that OS does not write to the disk (because I used the diskpart command
att vol set readonly). Each incarnation of sums-host or sums-guest does not differ from the previous one, but there's about 2000 different lines between sums-host and sums-guest