VDI image resize yields unbootable VDI

Description

Using

VBoxManage modifymedium disk <file> --resize <size>

in VirtualBox 5.1.6 r110634 turns the VDI image (no snapshots used) into an unbootable medium, i.e., the MBR is garbage.

In my specific case, the capacity of the image before resize is 64000 MBytes (61599 MBytes size on disk). I tried 68000 MBytes and 72000 MBytes as resize goal. Both operations complete almost instantly without error and

VBoxManage showhdinfo <file>

outputs the correct capacity and unchanged size of disk.

I used resize before with other VirtualBox versions on this image and it was never a problem.

Change History

I couldn't reproduce this so far so it must be dependent on the order the blocks are stored in the image. Can you please extract the first 3145728 bytes of the image before the resize (assuming you still have an unmodified backup) and attach it to the ticket?

I performed a resize with VirtualBox version 5.0.24 r108355 (Ubuntu 16.04.1) and it worked. Hence, there must be a regression in between version 5.0.24 r108355 and version 5.1.6 r110634. I also compiled VirtualBox from the sources (trunk). The bug was also present there.

Note that I cannot send the first 3145728 bytes since they contain actual data. From my understanding of the VDI file format, the data I submitted should be enough to understand the problem. It would be great if you could find the regression.

The data you sent is not complete as it chops off a part of the block table which is used to map the logical block number to offsets in the image file. I need the complete table to create an image with which I can hopefully replicate your issue. Your header indicates that real data in the image starts at offset 1048576 which is 1MB into the image, so please attach at least the first 1MB of the image which does not contain any data from the guest.