[Solved] VDI Invalid Header

Discussions related to using VirtualBox on Windows hosts.
haoc
Posts: 7
Joined: 24. Sep 2016, 12:21

Re: [Solved] VDI Invalid Header

Post by haoc »

mpack wrote: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.

I am sorry about it but could I know how to get the binary data from my VDI. I used hex Editor Neo and I cannot get the binary data. Also, I tried to use Frhed. It is wired that Frhed cannot load my file because of not enough memory.
Thanks
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] VDI Invalid Header

Post by mpack »

With Frhed you use "Open partially...", load 2097152 bytes then "Save as" to another file.
haoc
Posts: 7
Joined: 24. Sep 2016, 12:21

Re: [Solved] VDI Invalid Header

Post by haoc »

Sorry about my bad. the file is attached. I used Frhed to extract it. hope it makes sense.

Cheers
Attachments
myfile.7z
(89.59 KiB) Downloaded 19 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: [Solved] VDI Invalid Header

Post by mpack »

Ok, that's much better. Your disk is indeed corrupted, but it looks repairable by following these instructions :-

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 245760MB (240GB). 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 "A8 3C 02 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.
haoc
Posts: 7
Joined: 24. Sep 2016, 12:21

Re: [Solved] VDI Invalid Header

Post by haoc »

thanks for your help so much and now I can start the vm. However, I cannot log in to my system because one error occcurred thant UUID is not ready yet or not present. this problem is the rare one you mentioned in the end? could you please have a look at my snapshots
Attachments
Capture1.JPG
Capture1.JPG (24.48 KiB) Viewed 5545 times
Capture.JPG
Capture.JPG (30.37 KiB) Viewed 5545 times
haoc
Posts: 7
Joined: 24. Sep 2016, 12:21

Re: [Solved] VDI Invalid Header

Post by haoc »

Hi mpack. I used recovery mode to recovery the error in /home. Finally I got my system back.
Thank you for your help and time so much.
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] VDI Invalid Header

Post by mpack »

Yes, as mentioned in the instructions, creating a new header for a VDI means it gets a new UUID as well, which is what GRUB was complaining about. Generally you just change the grub script to expect the new UUID, or better yet have it choose the disk by device location instead of UUID. I'm not up on Linux hard disk IDs, but I believe its something like /dev/sda for the first hdd - Google for accurate instructions. It's a good idea to do this anyway, otherwise this problem is going to reoccur every time the hdd UUID changes, e.g. after cloning the VM.
shaunole
Posts: 4
Joined: 16. Nov 2016, 16:24

Re: [Solved] VDI Invalid Header

Post by shaunole »

Hey mpack - I've spent the last few days trying to repair an invalid pre header, convert the VDI to RAW and mount it to another Linux VM to no avail. I'm hoping you can help me out as well. Should I start a new thread with my details, send a PM (if you're available to help) or post here?
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] VDI Invalid Header

Post by mpack »

See the above for my requirements (including the exact size in bytes of the VDI), but open your own topic.
CMK
Posts: 1
Joined: 5. Apr 2017, 08:57

Re: [Solved] VDI Invalid Header

Post by CMK »

Hi Mpack,

Am facing the same VDI: invalid header issue. Shall I share you the first 2MB of my VDI?

Thanks in Advance.
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] VDI Invalid Header

Post by mpack »

Actually it isn't 2MB. It is 2097152 bytes, which is a bit more than 2MB. Yes, you can provide that, plus the other stuff I asked for above (logical disk size, current exact size in bytes of the VDI file). I'll take a look when I have time.

However I suggest that you open your own topic for this.
aquemy
Posts: 4
Joined: 5. Jan 2018, 16:16

Re: [Solved] VDI Invalid Header

Post by aquemy »

Hello,

I have the same problem and there are very important and urgent file on this disk.
The VDI is 300 119 228 416 bytes long (279,51 GB) and as far as I remember 1To logical size.

Can someone help me to fix the problem?

When you say "When you get to the disk creation step, create a disk which is exactly 245760MB (240GB). I will call this "the dummy vdi"." do you mean logical size or fixed physical size?
Attachments
hexdump.7z
(116.23 KiB) Downloaded 10 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: [Solved] VDI Invalid Header

Post by mpack »

Download CloneVDI and run it. The repair procedure is automated now.
aquemy
Posts: 4
Joined: 5. Jan 2018, 16:16

Re: [Solved] VDI Invalid Header

Post by aquemy »

Thanks you for your reply.
Is that possible to repair without copying the file ? I do not have enough space on my hardrive (and the VM size is bigger than half of the hard drive size anyway) ?
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] VDI Invalid Header

Post by mpack »

No, that is not possible. The clue is in the name CLONEvdi. Everything that CloneVDI does involves cloning, then modifying the clone.

You can either tell CloneVDI to write the output to another drive, or you can move the whole lot to another PC and do it there.

Yes, it's a pity that you gave the VM such a large virtual drive. That was pretty much guaranteed to become a problem. Most of my VMs have 32GB or 64GB drives.
Post Reply