[Solved] Corrupted VDI after host crash: VERR_VD_VDI_INVALID_HEADER

Discussions related to using VirtualBox on Windows hosts.
Post Reply
fotone123
Posts: 3
Joined: 24. Jun 2017, 02:13

[Solved] Corrupted VDI after host crash: VERR_VD_VDI_INVALID_HEADER

Post by fotone123 »

Dear all,
after a host (windows7) crash, my VM with Ubuntu can not boot anymore. The message I got is: "failed to open session " with the error "VERR_VD_VDI_INVALID_HEADER" . I tried to convert the vdi to raw and then to mount it in a fresh linux installation, in order to try at least to recover a couple of important files at which I was working... no success. Could you help me? Following discussions on this forum I attach to this post the first 2MB+1k of my corrupted vdi.
I hope that someone (mpack in particular) can give me good news since it is a two week job I'm going to loose. :(
Thanks in advance,
Gianluca
Attachments
corrupted.zip
(21.01 KiB) Downloaded 129 times
Last edited by fotone123 on 24. Jun 2017, 19:32, edited 1 time in total.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Corrupted VDI after host crash: VERR_VD_VDI_INVALID_HEADER

Post by mpack »

You should also have seen that I need the exact length of the VDI file, in bytes.
fotone123
Posts: 3
Joined: 24. Jun 2017, 02:13

Re: Corrupted VDI after host crash: VERR_VD_VDI_INVALID_HEADER

Post by fotone123 »

mpack wrote:You should also have seen that I need the exact length of the VDI file, in bytes.
Sorry! I forgot: 11.777.605.632 bytes .

Thanks,
Gianluca
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Corrupted VDI after host crash: VERR_VD_VDI_INVALID_HEADER

Post by mpack »

Ok, I have a recovery procedure for you. Please perform the following steps very carefully, because I am not there to look over your shoulder and correct you.

Incidentally, the hex editor I use is called frHed. I will assume that any other hex editor you use has the same capability as frHed.
  1. First, back up your existing VDI, if you have not already done so. It is important that nothing we do here can make matters worse.
    .
  2. Next, use VirtualBox to create a new dynamic VDI which has a capacity of 20490MB exactly. You may find it convenient to create a new VM inside which you can create this VDI, however the VM is temporary and will never actually be used, so you don't need to spend any time on the VM settings.
    .
  3. Using FrHed, copy only the first 512 bytes from the new vdi to offset zero in the damaged vdi (i.e. overwrite the old damaged header). You can then close the "new VDI", this is no longer required.
    .
  4. Again using FrHed, edit the four bytes at offset 388 (0x184). These four bytes should currently be "00 00 00 00". Change them to be "DE 2B 00 00".
    .
  5. Save changes and exit FrHed. The VDI header should now be repaired.
    .
Note that this repair involved creating a new VDI header which therefore has new disk UUIDs. This can sometimes cause problems for a grub boot, in which case you'd have to edit the grub script to change the boot drive UUID.

And may I suggest that if your data is important to you then you should make proper backups to secondary storage every time you accumulate enough changes that you wouldn't enjoy losing it. You've already seen that the danger is not just theoretical, and I can only repair headers - I can't recover lost data.
fotone123
Posts: 3
Joined: 24. Jun 2017, 02:13

Re: Corrupted VDI after host crash: VERR_VD_VDI_INVALID_HEADER

Post by fotone123 »

Thank you very much mpack!!!
I managed to recover the VM and all my files. I will follow your advice for the future: always backup important stuffs!
Thanks again, your help is very valuable!
ciao
Gianluca
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: [Solved] Corrupted VDI after host crash: VERR_VD_VDI_INVALID_HEADER

Post by mpack »

You're welcome, thanks for reporting back.
Reilight
Posts: 1
Joined: 28. Aug 2018, 11:37

Re: [Solved] Corrupted VDI after host crash: VERR_VD_VDI_INVALID_HEADER

Post by Reilight »

Since This reply will go to history then I would express my gratitute to mpack, Thanks for saving my only VDI wihch has been corrupted by power outage CRASH

VERR_VD_VDI_INVALID_HEADER
is really trouble some, however if you follow above tutorial by mpack, i think you will have a chance to restart the system.

This is what I have done:
1. Get a hex tool, any will do, I hv been using FREE HEX EDITOR NEO in this case and works very well
2. Create a BACKUP of the CORRUPTED VDI, and BACKUP of everything else
3. EDIT the HEX as per mpack tutorial above
4. Change the UUID of the VDI using CMD as ADMIN in virtualbox directory-> vboxmanage internalcommands sethduuid "YOUR VDI PATH"
5. Restart the system in virtualbox and hope for the best

in my case there hv been error of locked VDI, however please do not give up as you will find your answer in google.

MORAL OF THE STORY:
- VM IS GOOD, BUT PLEASE BACKUP ALL OF YOUR IMPORTANT DATA OUTSIDE VM EVERYDAY

And thats my story, this is not the only virtual machine error that I hv been dealing, and to all people who reading this forum, please do not give up upon restarting your VM

Thank you Mpack!
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: [Solved] Corrupted VDI after host crash: VERR_VD_VDI_INVALID_HEADER

Post by mpack »

Well thanks for the compliments, but the above advice was specific to user fotone123. There is no chance of repairing anyone else's VDI by following that advice without modification. Attempting it would corrupt the VM further, and I find it hard to believe that the vdi would pass VirtualBox validation.

In any case my older advice is obsolete, since as of July 2017 the associated repair technique is now automated and built into CloneVDI (v3.0 and later).
Post Reply