[Solved] Invalid Header in vdi

Discussions related to using VirtualBox on Windows hosts.
Softmaster
Posts: 7
Joined: 22. Aug 2015, 12:27

[Solved] Invalid Header in vdi

Post by Softmaster »

Hi all! Please help in my problem. My computer is dramatically restart when i use virtual machine. after restart my computer my VM can`t started. i receive a meessage - (VERR_VD_VDI_INVALID_HEADER).
Please help!
loukingjr
Volunteer
Posts: 8851
Joined: 30. Apr 2009, 09:45
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: just about all that run

Re: Invalid Header in vdi

Post by loukingjr »

OSX, Linux and Windows Hosts & Guests
There are three groups of people. Those that can count and those that can't.
Softmaster
Posts: 7
Joined: 22. Aug 2015, 12:27

Re: Invalid Header in vdi

Post by Softmaster »

sorry!
1. version of VirtualBox - 5.0.0 r 101573
2. Host - Win 7 Home x64 Memory 8 Gb; Guest - Win7 Pro x 64 Memory 4 Gb
Error:

Could not open the medium 'E:\VD\VD\delphi_7.vdi'.

VDI: invalid header in 'E:\VD\VD\delphi_7.vdi' (VERR_VD_VDI_INVALID_HEADER).

VD: error VERR_VD_VDI_INVALID_HEADER opening image file 'E:\VD\VD\delphi_7.vdi' (VERR_VD_VDI_INVALID_HEADER).

Код ошибки: E_FAIL (0x80004005)
Компонент: MediumWrap
Интерфейс: IMedium {4afe423b-43e0-e9d0-82e8-ceb307940dda}
Attachments
logs.zip
(22.46 KiB) Downloaded 13 times
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Invalid Header in vdi

Post by mpack »

Actually, the logs are pretty useless for diagnosing this error.

Diagnosis should be easy by inspection: the error message says that "E:\VD\VD\delphi_7.vdi" is not really a VDI. It should be easy to verify this yourself, e.g. check the file size, examine the first few KB of the file using a hex editor and compare with a known good VDI. If the file has been copied from elsewhere and the size and first few KB look right, then compare md5 checksums.
Softmaster
Posts: 7
Joined: 22. Aug 2015, 12:27

Re: Invalid Header in vdi

Post by Softmaster »

What structure should be at the file header?
i check normal file -
Offset 0 1 2 3 4 5 6 7 8 9 A B C D E F

000000000 3C 3C 3C 20 4F 72 61 63 6C 65 20 56 4D 20 56 69 <<< Oracle VM Vi
000000010 72 74 75 61 6C 42 6F 78 20 44 69 73 6B 20 49 6D rtualBox Disk Im
000000020 61 67 65 20 3E 3E 3E 0A 00 00 00 00 00 00 00 00 age >>>
000000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000000040 7F 10 DA BE 01 00 01 00 90 01 00 00 01 00 00 00 Ú¾
000000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000000090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000000A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000000B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000000C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000000D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000000E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000000F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000000110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000000120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000000130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000000140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000000150 00 00 00 00 00 00 10 00 00 00 20 00 00 00 00 00
000000160 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00
000000170 00 00 00 B1 08 00 00 00 00 00 10 00 00 00 00 00 ±
000000180 10 8B 00 00 A4 82 00 00 36 EA 63 87 71 3B 57 43 ‹ ¤‚ 6êc‡q;WC
000000190 8D 4A 1F 88 F0 3A 57 DE 76 8E C5 D3 2E 16 CE 4E J ˆð:WÞvŽÅÓ. ÎN
0000001A0 8A F1 CC EC 57 C3 03 67 00 00 00 00 00 00 00 00 ŠñÌìWà g
0000001B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000001C0 00 00 00 00 00 00 00 00 00 04 00 00 FF 00 00 00 ÿ
0000001D0 3F 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 ?

i check corrupt file -
Offset 0 1 2 3 4 5 6 7 8 9 A B C D E F

000000000 3C 3C 3C 20 4F 72 61 63 6C 65 20 56 4D 20 56 69 <<< Oracle VM Vi
000000010 72 74 75 61 6C 42 6F 78 20 44 69 73 6B 20 49 6D rtualBox Disk Im
000000020 61 67 65 20 3E 3E 3E 0A 00 00 00 00 00 00 00 00 age >>>
000000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000000040 7F 10 DA BE 01 00 01 00 90 EE 10 05 00 00 00 00 Ú¾ î
000000050 0A D9 E7 E6 FE 07 00 00 00 F1 10 05 00 00 00 00 Ùçæþ ñ
000000060 E4 09 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ä
000000070 63 25 BC FC FE 07 00 00 48 00 00 00 00 00 00 00 c%¼üþ H
000000080 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000000090 00 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 0
0000000A0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
0000000B0 43 25 BC FC FE 07 00 00 00 00 00 00 00 00 00 00 C%¼üþ
0000000C0 00 00 00 00 00 00 00 00 00 00 00 00 00 80 FF FF €ÿÿ
0000000D0 A0 6F C8 03 00 00 00 00 FF FF FF FF 00 00 00 00  oÈ ÿÿÿÿ
0000000E0 18 C1 E7 E6 FE 07 00 00 00 06 C9 03 00 00 00 00 Áçæþ É
0000000F0 FF FF FF FF 00 00 00 00 01 00 00 00 00 00 00 00 ÿÿÿÿ
000000100 E8 09 00 00 00 00 00 00 FF FF FF FF 00 00 00 00 è ÿÿÿÿ
000000110 EB BC E6 E6 FE 07 00 00 A0 6F C8 03 00 00 00 00 ë¼ææþ  oÈ
000000120 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
000000130 E4 09 00 00 00 00 00 00 F0 26 89 08 00 00 00 00 ä ð&‰
000000140 C4 F4 19 E3 FE 07 00 00 F0 26 89 08 00 00 00 00 Äô ãþ ð&‰
000000150 E0 3A 74 08 00 00 00 00 00 00 00 00 00 00 00 00 à:t
000000160 00 00 00 00 00 00 00 00 20 C8 89 08 00 00 00 00 ȉ
000000170 37 07 1A E3 FE 07 00 00 F0 26 89 08 00 00 00 00 7 ãþ ð&‰
000000180 A0 FE DD 03 00 00 00 00 E0 3A 74 08 00 00 00 00  þÝ à:t
000000190 A0 FE DD 03 00 00 00 00 A0 FE DD 03 00 00 00 00  þÝ  þÝ
0000001A0 C9 E9 19 E3 FE 07 00 00 20 C8 89 08 00 00 00 00 Éé ãþ ȉ
0000001B0 E0 3A 74 08 00 00 00 00 11 00 00 00 00 00 00 00 à:t
0000001C0 00 00 00 00 00 00 00 00 D0 04 89 08 00 00 00 00 Ð ‰
0000001D0 42 02 7D E2 FE 07 00 00 00 00 00 00 00 00 00 00 B }âþ

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

Re: Invalid Header in vdi

Post by mpack »

Try opening the VDI using CloneVDI, see if it also reports an error. See also if the filesize is consistent with the header (file size should be around (nBlocksAllocated+1)*MB, with nBlocksAllocated as reported by "Show Header".
Softmaster
Posts: 7
Joined: 22. Aug 2015, 12:27

Re: Invalid Header in vdi

Post by Softmaster »

i try open VDI and see message -
Source file corrupt - block map contains error
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Invalid Header in vdi

Post by mpack »

I am still waiting for you to answer my file size questions: it would be nice to have an exact current size in bytes, and a screenshot of the "Show Header" information from CloneVDI.

Let's be clear: you definitely have severe corruption of the VDI. The only sure way to recover that kind of corruption is with a backup copy, which I assume you don't have. Or, if this is a badly transported copy of another VDI, then you can just copy the original again.

As a last resort, it is sometimes possible to repair damaged VDIs, but it depends on the nature of the corruption. But to know if this is possible I need you to provide the details I've been asking for.
Softmaster
Posts: 7
Joined: 22. Aug 2015, 12:27

Re: Invalid Header in vdi

Post by Softmaster »

51 686 408 192 bites size of file
CloneVDI - damaged vdi not open.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Invalid Header in vdi

Post by mpack »

All right, lets try this. Use your hex editor to write the first 2MB of the VDI to a binary file, then compress that file and attach it here if the site will let you. Or provide a download link if you are signed up anywhere.
Softmaster
Posts: 7
Joined: 22. Aug 2015, 12:27

Re: Invalid Header in vdi

Post by Softmaster »

ok, this file.
Attachments
noname.zip
(70.28 KiB) Downloaded 40 times
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Invalid Header in vdi

Post by mpack »

Thanks. The good news is that it looks like it's only the header which is corrupted - though very badly. The block map looks fine, and the first part of the disk image is where it should be.

CloneVDI said "block map contains errors" because the header tells CloneVDI where the block map is stored, but that location is wrong and thus the supposed "block map" contains garbage.

Can you tell me what the disk capacity was intended to be?
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Invalid Header in vdi

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 VDI which has a capacity of 64GB. You can choose other capacities, but keep it above 50GB and below 256GB. You may find it convenient to create a new VM inside which you can create this VDI. The new VM should have the same OS type and similar settings to the original VM, because this new VM will eventually host the repaired VDI.
    .
  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 "8A C0 00 00".
    .
  5. Save changes and exit FrHed. The VDI should now be repaired.
    .
  6. Rename the damaged VDI to match the name of the new VDI created earlier. The repaired VDI is now a direct replacement for the "new VDI" in the new VM you created (i.e. internally it has the expected UUIDs). You should now be able to run the VM.
Softmaster
Posts: 7
Joined: 22. Aug 2015, 12:27

Re: Invalid Header in vdi

Post by Softmaster »

Thank you very much! All work after your instruction!
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Invalid Header in vdi

Post by mpack »

Excellent. I'm pleased for both of us. :)

May I suggest that you back this up soon, and repeat on a regular basis?
Post Reply