[TriLUG] Using dd to repair a VirtualBox .vdi file

Paul Boyle via TriLUG trilug at trilug.org
Tue May 26 11:03:52 EDT 2015


Hi,

I have a VirtualBox VM (guest is Windows7) hosted on my Linux laptop.
Recently (after upgrading to VirtualBox 4.3.28), the "main disk"  vdi
file got corrupted and the VM won't boot now.  The main disk file is
about 26GB in size. A little googling yielded this potentially useful
lead,

https://forums.virtualbox.org/viewtopic.php?f=6&t=45192

Following the advice, I created a 72 byte preheader from a good .vdi
file (I used 'head -c72 good_disk.vdi > preheader.vdi' )

I could write a C or python program to try to make the repair, but I
thought I try to see if command line tools could do the trick.  I tried
using 'dd' in the following way:

cp preheader.vid new_disk.vdi

dd if=bad_disk.vdi skip=72c of=new_disk.vdi oflag=append conv=notrunc 

However, the sizes of bad_disk.vdi and new_disk.vdi are different.
They differ by 3679 bytes with the original file being slightly
larger.  I would think that the files should end up being exactly the
same size.

I was wondering if someone could advise me on what dd incantation would
skip the first 72 bytes of the bad_disk.vdi file and append the rest of
that file to new_disk.vdi.  Alternatively, if there is a better tool
than dd, I'm open to suggestions.

Thanks for any help.

Paul

-- 
Paul D. Boyle, Ph. D.
Manager, X-ray Facility
Department of Chemistry
Western University
London, ON N6A 5B7
Canada
GPG Fingerprint: 8ECE 516D 9046 FE83 4A46  7E8E D720 555D 8CC3 EC6B


More information about the TriLUG mailing list