Fix VDI with corrupted header

Issue:

Abrupt shutdown lead to corruption of VDI header due to which it could not be re-booted again.

 

Could not open the medium ‘C:\Users\mohit\VirtualBox VMs\Ubuntu-Working\LinuxAgain.vdi’.

VDI: invalid header in ‘C:\Users\mohit\VirtualBox VMs\Ubuntu-Working\LinuxAgain.vdi’ (VERR_VD_VDI_INVALID_HEADER).

VD: error VERR_VD_VDI_INVALID_HEADER opening image file ‘C:\Users\mohit\VirtualBox VMs\Ubuntu-Working\LinuxAgain.vdi’ (VERR_VD_VDI_INVALID_HEADER).

Result Code: E_FAIL (0x80004005)
Component: MediumWrap
Interface: IMedium {4afe423b-43e0-e9d0-82e8-ceb307940dda}

 

 

VBoxError

 

Environment:

Host: Windows 10 64 bit

Guest: Ubuntu 32 bit

VM Tool: Oracle Virtual Box 5.0.8

 

Fix:

Take back up of corrupted VDI as we are going to edit it.

Downloaded “Free Hex Editor Neo 6.20” using which VDIs could be edited.

Opened two VDIs using Hex Editor:

  1. Corrupted
  2. Working (This also had Ubuntu 32 bit version, do not know if it would work if not this)

 

HexEdi-2

 

From Original VDI, copy data until you see all dots there after.

For me it was 465 bytes, displayed in in Right Side “Information” pane.

HexEdi-3

 

Then go to corrupted VDI, go to start of the data & paste & save.

 

HexEdi-4

 

If this VDI name is still same as configured in VM and still present at the same position then it should work.

 

But i tried creating new VM using corrupted->fixed VDI and ran into the another issue of UUID clash. Please find details below.

(Following screenshot & error are taken from internet, therefore will not match my environment details)

 

Error:

“Failed to open the hard disk E:\VirtualBox VMs\Windows 8 \Windows 8 Enterprise2.vhd.

Cannot register the hard disk ‘E:\VirtualBox VMs\Windows 8 \Windows 8 Enterprise2.vhd’{ca2bdc6a-a487-4e57-9fcd-509d0c31d86d} because a hard disk ‘E:\VirtualBox VMs\Windows 8 Enterprise\Windows 8 Enterprise2.vhd’ with UUID {ca2bdc6a-a487-4e57-9fcd-509d0c31d86d} already exists.

Result Code:
E_INVALIDARG (0x80070057)

Component:
VirtualBox

Interface:
IVirtualBox {3b2f08eb-b810-4715-bee0-bb06b9880ad2}

Callee RC:
VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)”

 

HexEdi-5

 

 

Fix:

Reset the UUID of corrupted->fixed VDI

cd C:\Program Files\Oracle\VirtualBox\

VBOXMANAGE.EXE internalcommands sethduuid “pathtovhdfile”

HexEdi-6

Now try re-loading this VDI into existing VDI or try creating new VM using this.

It should work out. Good luck.