[Solved] VDI Invalid Header

Discussions related to using VirtualBox on Windows hosts.
vicsana1
Posts: 5
Joined: 31. Mar 2016, 17:06

[Solved] VDI Invalid Header

Post by vicsana1 »

Hi,

I was working with my Lubuntu virtual machine on my laptop when I had to change rooms and closed it (the laptop, physically). After opening the laptop again my VM would not work anymore indicating that the vdi header is not valid. My host machine is a Windows 7. The VDI itself is dynamic allocation.

I have tried many of these forum solutions with no success. Finally, I have used an hex editor to check the first 1024 bytes of the vdi file.

VBox error:
Failed to open a session for the virtual machine Lubuntu.

Could not open the medium 'C:\Users\ac0872\VirtualBox VMs\Lubuntu\Lubuntu.vdi'.

VDI: invalid header in 'C:\Users\ac0872\VirtualBox VMs\Lubuntu\Lubuntu.vdi' (VERR_VD_VDI_INVALID_HEADER).

VD: error VERR_VD_VDI_INVALID_HEADER opening image file 'C:\Users\ac0872\VirtualBox VMs\Lubuntu\Lubuntu.vdi' (VERR_VD_VDI_INVALID_HEADER).

Result Code: E_FAIL (0x80004005)
Component: MediumWrap
Interface: IMedium {4afe423b-43e0-e9d0-82e8-ceb307940dda}
Hex content:
000 3c 3c 3c 20 4f 72 61 63 6c 65 20 56 4d 20 56 69 72 74 75 61 6c 42 6f 78 20 44 69 <<< Oracle VM VirtualBox Di
01b 73 6b 20 49 6d 61 67 65 20 3e 3e 3e 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 sk Image >>>...............
036 00 00 00 00 00 00 00 00 00 00 7f 10 da be 01 00 01 00 90 f1 21 08 00 00 00 00 9a ............Ú¾.....ñ!......
051 db a1 d3 fe 07 00 00 02 00 00 00 00 00 00 00 40 f1 21 08 00 00 00 00 00 00 00 00 Û¡Óþ...........@ñ!.........
06c 00 00 00 00 ac 10 52 fd fe 07 00 00 c0 e5 83 05 00 00 00 00 48 3d 9e d3 fe 07 00 ....¬.Rýþ...Àå......H=.Óþ..
087 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
0a2 00 00 00 00 00 00 48 00 00 00 00 00 00 00 01 00 00 00 fe 07 00 00 00 00 00 00 00 ......H...........þ........
0bd 00 00 00 00 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff ...........0.......ÿÿÿÿÿÿÿÿ
0d8 ff ff ff ff ff ff ff ff 53 25 52 fd fe 07 00 00 00 00 00 00 00 00 00 00 f0 7b 85 ÿÿÿÿÿÿÿÿS%Rýþ...........ð{.
0f3 05 00 00 00 00 00 00 00 00 00 00 00 00 50 7d 85 05 00 00 00 00 ff ff ff ff 00 00 .............P}......ÿÿÿÿ..
10e 00 00 a8 c3 a1 d3 fe 07 00 00 00 ed 8c 05 00 00 00 00 ff ff ff ff 00 00 00 00 01 ..¨Ã¡Óþ....í......ÿÿÿÿ.....
129 00 00 00 00 00 00 00 d0 0d 00 00 00 00 00 00 ff ff ff ff 00 00 00 00 bb bd a0 d3 .......Ð.......ÿÿÿÿ....»½ Ó
144 fe 07 00 00 50 7d 85 05 00 00 00 00 a8 dd b3 0b 00 00 00 00 00 00 20 00 00 00 00 þ...P}......¨Ý³....... ....
15f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 85 08 a0 d1 fe 07 00 00 60 4c ................... Ñþ...`L
17a 8f 05 00 00 00 00 f0 7b 85 05 00 00 00 00 a8 dd b3 0b 00 00 00 00 b5 98 c7 71 6f ......ð{......¨Ý³.....µ.Çqo
195 cf 1f 0e 00 00 00 00 00 00 00 00 1d a7 30 f1 fe 07 00 00 00 a2 fe 21 00 00 00 00 Ï...........§0ñþ....¢þ!....
1b0 30 2c 8c 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 58 47 0,.......................XG
1cb f8 0d 00 00 00 00 00 00 00 00 80 ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ø..........ÿÿ..............
1e6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
201 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
21c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
237 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
252 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
26d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
288 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
2a3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
2be 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
2d9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
2f4 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
30f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
32a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
345 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
360 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
37b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
396 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
3b1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
3cc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...........................
3e7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .........................
VBox.log:
VirtualBox VM 5.0.2 r102096 win.amd64 (Aug 13 2015 17:23:32) release log
00:00:02.398920 Log opened 2016-03-31T15:02:08.344530700Z
00:00:02.398922 Build Type: release
00:00:02.398924 OS Product: Windows 7
00:00:02.398926 OS Release: 6.1.7601
00:00:02.398928 OS Service Pack: 1
00:00:02.514067 DMI Product Name: HP ZBook 15u G2
00:00:02.518772 DMI Product Version: A3009D510203
00:00:02.518772 Host RAM: 8067MB total, 5746MB available
00:00:02.518772 Executable: C:\Program Files\Oracle\VirtualBox\VirtualBox.exe
00:00:02.518772 Process ID: 3716
00:00:02.518772 Package type: WINDOWS_64BITS_GENERIC
00:00:02.527590 Installed Extension Packs:
00:00:02.527627 None installed!
00:00:02.532981 Console: Machine state changed to 'Starting'
00:00:02.535125 GUI: UIMediumEnumerator: Medium-enumeration finished!
00:00:02.539500 Console: Machine state changed to 'PoweredOff'
00:00:02.612600 Power up failed (vrc=VINF_SUCCESS, rc=E_FAIL (0X80004005))
00:00:02.893268 GUI: UIMachineViewNormal::resendSizeHint: Restoring guest size-hint for screen 0 to 1024x606
00:00:02.893335 ERROR [COM]: aRC=E_ACCESSDENIED (0x80070005) aIID={7303a66d-433b-25a4-f9a8-fcadf87e0c2a} aComponent={DisplayWrap} aText={The console is not powered up}, preserve=false aResultDetail=0
Is it possible to recover the files? I have a very important presentation that I would like to recover.

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

Re: VDI Invalid Header

Post by mpack »

Use your hex editor to save the first 2M+1024 bytes (2098176 bytes total) of the VDI to a new file. Zip that file and attach here. I'll take a look.
vicsana1
Posts: 5
Joined: 31. Mar 2016, 17:06

Re: VDI Invalid Header

Post by vicsana1 »

Thank you!
Please find attached the hex dump

hexdump.7z
Last edited by mpack on 2. Apr 2016, 18:55, edited 1 time in total.
Reason: Deleted unwanted attachment.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: VDI Invalid Header

Post by mpack »

Uh, I need it in binary, not converted into a text file. I want to load the header data into a debugger and potentially repair it, not just look at it.

While you're at it you could tell me the exact size in bytes of the VDI file. The logical size of the drive would be useful too.
vicsana1
Posts: 5
Joined: 31. Mar 2016, 17:06

Re: VDI Invalid Header

Post by vicsana1 »

Sorry about that, I did not know.
Now I am attaching the binary header. The total size for the file is 65,873,641,472 bytes, and I believe it is the same logical size as space was dynamically allocated although I am not sure.

Thank you so much for the help!
Attachments
dump.7z
(30.33 KiB) Downloaded 124 times
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: VDI Invalid Header

Post by mpack »

Very strange. The header has been thoroughly destroyed, however the preheader is intact.

The good news is that the block map is intact, and all the numbers add up (e.g. file size matches block map), so this VDI is repairable.

Steps (please follow very carefully).
  1. Make a copy of the VDI (using the host OS) and set aside as a backup.
  2. In VirtualBox File|Virtual Media Manager, Release and then Remove the damaged VDI. Do NOT delete the physical file.
  3. Use VirtualBox to create a new VM - the details other than the disk don't matter since you will never run this VM. When you get to the disk creation step, create a disk which is exactly 81920MB (80GB). I will call this "the dummy vdi".
  4. With a hex editor, copy the first 512 bytes from the dummy VDI, and use it to overwrite the first 512 bytes of the damaged VDI.
  5. Still using your hex editor, edit the 4 bytes at file offset 388 (0x184). The new values should be "64 F5 00 00".
  6. Save changes to the damaged VDI (after this it will no longer be damaged).
  7. In the settings for your original VM, select the controller, click the "Add hard disk" icon, and select your repaired VDI (which should still be in the original VM folder).
  8. The VM should now be repaired as far as VirtualBox is concerned.
Be aware that the VDI now has a completely new header, including a new UUID. I note that you are using a Grub boot - sometimes (rarely), Grub uses the UUID to identify the disk it needs to boot from, and will fail if the UUID changes. But, we can cross that bridge if and when we come to it.

You can delete that dummy/donor VM at any time, using the GUI of course.
vicsana1
Posts: 5
Joined: 31. Mar 2016, 17:06

Re: VDI Invalid Header

Post by vicsana1 »

Thank you for the quick reply!

I have done as you suggested, but it seems that I run into the UUID problem:
UUID {fd236a26-2ebc-4709-a27e-b6f20ec3c09a} of the medium 'C:\Users\ac0872\VirtualBox VMs\Lubuntu\Lubuntu.vdi' does not match the value {4fffb135-559a-4996-b598-c7716fcf1f0e} stored in the media registry ('C:\Users\ac0872/.VirtualBox\VirtualBox.xml').
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: VDI Invalid Header

Post by mpack »

See step 2 in my instructions. If you get that error then you did not complete that step.
vicsana1
Posts: 5
Joined: 31. Mar 2016, 17:06

Re: VDI Invalid Header

Post by vicsana1 »

It worked!

Thank you so much for all the help! You really saved my work! I appreciate all the effort.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: [Solved] VDI Invalid Header

Post by mpack »

Excellent, thanks for reporting back.
haoc
Posts: 7
Joined: 24. Sep 2016, 12:21

Re: [Solved] VDI Invalid Header

Post by haoc »

hi, mpack

I got the same problem of VDI Invalid Header and I tried to follow the steps you mentioned.
I had a question about changing four bytes offsetting 388 (0x184). how could I get these four bytes because I thought each VM has its own bytes?

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

Re: [Solved] VDI Invalid Header

Post by mpack »

The above solution is unique to vicsana1. If you want a solution that is unique to you then I need the same data which Vicsana provided, i.e. the first 2MB of the VDI file, zipped. Plus the exact VDI file size in bytes and the logical disk size.
haoc
Posts: 7
Joined: 24. Sep 2016, 12:21

Re: [Solved] VDI Invalid Header

Post by haoc »

mpack wrote:The above solution is unique to vicsana1. If you want a solution that is unique to you then I need the same data which Vicsana provided, i.e. the first 2MB of the VDI file, zipped. Plus the exact VDI file size in bytes and the logical disk size.
thanks first. I am crazy about it. ==) the file is attached. please have a look.

Cheers

corrupt.7z
haoc
Posts: 7
Joined: 24. Sep 2016, 12:21

Re: [Solved] VDI Invalid Header

Post by haoc »

mpack wrote:The above solution is unique to vicsana1. If you want a solution that is unique to you then I need the same data which Vicsana provided, i.e. the first 2MB of the VDI file, zipped. Plus the exact VDI file size in bytes and the logical disk size.
Plus, The total size of VDI is 153,723,338,752 bytes. I am not sure about the logical size is 2.4e+11 byte (240GB)
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: [Solved] VDI Invalid Header

Post by mpack »

The data in the file you provided does not come from a VDI file.

Please be aware that most free undelete tools are snake oil. If that's what you used to recover this file then it didn't work even slightly.

Ah, now I see. You have provided an ascii hex dump. Is it completely inappropriate for me to expect that you read the guidance on what I need from the discussion above?

I need binary data, not an ascii dump.
Post Reply