[vbox-dev] vhd resize corruption

Aaron Brice aaron.brice at datasoft.com
Fri Aug 29 19:14:47 GMT 2014


So the 40GB .vhd file that contained a Windows 7 VM was running out of 
room, and I wanted to resize it.

With VBoxManage 4.3.10 on Ubuntu I ran:

VBoxManage modifyhd --resize 61440

Anyway, long story short it won't boot, gparted live ISO doesn't find a 
partition table..

So I started investigating the .vhd file format.  There is 512 bytes in 
the beginning consisting of a copy of the footer, then 1024 bytes of the 
header, then a variably sized BAT (Block Allocation Table), then the 
blocks of data.  When the max size of the disk changes the BAT has to be 
resized to accommodate potential new blocks.  It looks like modifyhd 
resizes the BAT, but did not shift the BAT pointers or move the data, it 
just expanded the BAT into the first data block, wiping out the MBR.  I 
don't have the original for comparison, but now the first entry in the 
BAT is 0xa3 (163).  This used to point to the sector just after the BAT, 
but now the BAT has expanded (from 20480 4-byte entries to 30720) and 
sector 163 is entry 20481 in the table, and the MBR table is all 0xff's..

Relevant bug: https://www.virtualbox.org/ticket/11960

Thanks,
Aaron







More information about the vbox-dev mailing list