Corrupted VDI file

This is for discussing general topics about how to use VirtualBox.
Post Reply
Beralus
Posts: 4
Joined: 4. Jul 2017, 04:31

Corrupted VDI file

Post by Beralus »

Hi. I do not remember if i turned off VirtualBox machine properly or not, but was not able restart(reuse) this machine again.
Both of host(win 10) and guest(win 7) are windows machine . VBox version is 5.1.18 r114002 (Qt5.6.2)
So. I get this error :

Code: Select all

Could not open the medium 'D:\VirtualBox\Win_7_32_1\NTFS_90GB.vdi'.
VDI: invalid header in 'D:\VirtualBox\Win_7_32_1\NTFS_90GB.vdi' (VERR_VD_VDI_INVALID_HEADER).
VD: error VERR_VD_VDI_INVALID_HEADER opening image file 'D:\VirtualBox\Win_7_32_1\NTFS_90GB.vdi' (VERR_VD_VDI_INVALID_HEADER).


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

But using Linux version of Oracle box i meet another error (unsupported format).
I did a google search, but nothing succeed.(I do not think header is corruped /(see attachment))
I ve used a few recovere tools including R-studio recovery to extract data. I see File System stucture as they were , even able to extract any file but content of the extracted file is quite different and ununderstandable...
Is there any way to recover files from corrupted VDI image
Attachments
Capture.PNG
Capture.PNG (67.56 KiB) Viewed 11505 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: Corrupted VDI file

Post by mpack »

VirtualBox doesn't lie. The header is corrupted, otherwise you would not get that error.

If you want me to address this problem then I need a zip containing the first 2098176 bytes from the VDI. I also need the exact current size of the VDI file, in bytes.
Beralus
Posts: 4
Joined: 4. Jul 2017, 04:31

Re: Corrupted VDI file

Post by Beralus »

Thank you for your attention.

Code: Select all

$ dd if=NTFS_90GB.vdi of=first2098176.bytes  bs=2098176 count=1
 $  zip -rv first2098176.bytes.zip  first2098176.bytes
$ ls -l | grep *.bytes
-rw-rw-r--   1 fc25   fc25       2098176 Jul  4 13:50 first2098176.bytes
-rw-rw-r--   1 fc25   fc25        101632 Jul  4 13:52 first2098176.bytes.zip
by the way i get another error when trieng to attach this VDI disk under linux (VirtualBox Graphical User Interface Version 5.1.14 r112924)

Code: Select all

Failed to open the disk image file /mnt/sda10/NTFS_90GB.vdi.

Could not get the storage format of the medium '/mnt/sda10/NTFS_90GB.vdi' (VERR_NOT_SUPPORTED).

Result Code: VBOX_E_IPRT_ERROR (0x80BB0005)
Component: MediumWrap
Interface: IMedium {4afe423b-43e0-e9d0-82e8-ceb307940dda}
Callee: IVirtualBox {0169423f-46b4-cde9-91af-1e9d5b6cd945}
Callee RC: VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)
VDI is dynamic sized

Code: Select all

$ ls -l *.vdi

-rwxrwxrwx 1 fc25 25  70123520000 Jun 30 23:24 NTFS_90GB.vdi
[me@HPComp sda10]$ 

Attachments
first2098176.bytes.zip
(99.25 KiB) Downloaded 244 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: Corrupted VDI file

Post by mpack »

The VDI was definitely corrupted. For some reason the preheader was ok (with the visible strings), but everything else I checked was garbage. Happily the blockmap and image are intact so the file is recoverable.

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 exactly 90GB (92160MB). 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 "39 05 01 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.
Beralus
Posts: 4
Joined: 4. Jul 2017, 04:31

Re: Corrupted VDI file

Post by Beralus »

Thank your, Ser! Accept my gratitude. Thanks for your correct and worty guide!
I did all steps as described . But after exluding only 4th piont of guide (Edit the four bytes at offset 388 (0x184). These four bytes should currently be "00 00 00 00". Change them to be "39 05 01 00".)
it worked. There was not any problem with UUIDs. Worked just after removing newly created VM.
Lots of 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: Corrupted VDI file

Post by mpack »

Are you saying that you omitted item 4? Why?

If yes then the repair was not done properly, whether or not it seems to work. You have a VDI header that doesn't describe its own image and will therefore destroy itself the next time it increases in size.
Beralus
Posts: 4
Joined: 4. Jul 2017, 04:31

Re: Corrupted VDI file

Post by Beralus »

Because after changing 4 byets at offset 388 to 39 05 01 00 get an error while attaching vdi to VM.So after comparision created vdi i changet them to 00 00 00 00 and it worked
After boting VDI attached VM i noticed that image modified by VM (HEX editor asked me reload or not changes).
Just now i 've changed above mentioned bytes to 39 05 01 00 . Works fine. But no changes noticed.
I can t tell aly opinion related with this one :' "You have a VDI header that doesn't describe its own image and will therefore destroy itself the next time it increases in size"
because have not write ,delete anithing or (increase disk size) yet. I hope it will not destroy itself , because i v already changed 4 byets at offset 388 to 39 05 01 00
maroz
Posts: 4
Joined: 4. Mar 2019, 23:32

Re: Corrupted VDI file

Post by maroz »

I have the same issue with corrupted VDI header. Could you please check if my VDI is recoverable?
My HDD size is 50GB and current VDI file size is 27805089792 bytes. I attached zip containing the first 2098176 bytes from the VDI.

Thanks,
Tomas
Attachments
first2098176.zip
First 2098176 bytes from the VDI
(40.26 KiB) Downloaded 91 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: Corrupted VDI file

Post by mpack »

I don't do manual repairs of VDIs any longer, since CloneVDI now automates the procedure. See the "VDI Repair" section of the release notes.

And yes, the header looks very recoverable, but it's not simple preheader corruption therefore CloneVDI will create a whole new header for it, which will change the UUIDs.

p.s. An acknowledgment that the feature works would be nice.
maroz
Posts: 4
Joined: 4. Mar 2019, 23:32

Re: Corrupted VDI file

Post by maroz »

Hi mpack, thanks for advice I used Clone VDI tool and it fixed my VDI.
FedeW
Posts: 4
Joined: 23. Mar 2020, 13:31

Re: Corrupted VDI file

Post by FedeW »

Hello mpack,

I have the same problem and there are very important and urgent file on this disk.
The VDI is 185.545.523.200 bytes (185,55 GB en el disco)

Attached dump file.

Coudl you help me?

Best regards.
Attachments
W7Pro64-header.zip
(245.86 KiB) Downloaded 25 times
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Corrupted VDI file

Post by scottgus1 »

@FedeW, I suspect that if you read just two posts up from yours, you will find advice from Mpack that will help you help yourself.
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 file

Post by mpack »

He has been cross posting this question for the last two days, and not reading any of the replies, so I wonder what is the point is??

Yesterday I answered his first post, and also locked a cross post while warning that this was against the rules. Today I find two more cross posts (deleting one). This is beginning to look like forum vandalism to me. Warning issued.

Just to add to the annoyance, the attachment is not the size requested. I don't think the request could have been much clearer: I gave the exact size in bytes, I did not indicate that this size should be treated as approximate.
Post Reply