VDI corrupted

Discussions related to using VirtualBox on Linux hosts.
Post Reply
itsme
Posts: 4
Joined: 22. Feb 2017, 15:27

VDI corrupted

Post by itsme »

Hallo!

Some days ago my virtualbox vm was very slow and after many weeks of saving it, i made a shutdown.

Some days later i want to boot it and virtualbox writes me:
Für die virtuelle Maschine Privater_Desktop_v2 konnte keine neue Sitzung eröffnet werden.

Could not open the medium '/home/oliver/vms/Privat/Privater_Desktop_v2/Privater_Desktop_v2-enc.vdi'.

VDI: invalid header in '/home/oliver/vms/Privat/Privater_Desktop_v2/Privater_Desktop_v2-enc.vdi' (VERR_VD_VDI_INVALID_HEADER).

VD: error VERR_VD_VDI_INVALID_HEADER opening image file '/home/oliver/vms/Privat/Privater_Desktop_v2/Privater_Desktop_v2-enc.vdi' (VERR_VD_VDI_INVALID_HEADER).

Fehlercode:NS_ERROR_FAILURE (0x80004005)
Komponente:MediumWrap
Interface:IMedium {4afe423b-43e0-e9d0-82e8-ceb307940dda}
Now when i start virtualbox its says me, that there is a problem with a virtual disk and i can ignore and proof/validate it. when i click validate i get the gui of the "manager for virtual devices".

There i see all virtual harddisk and the one with the problems.
All of them shows me size and end size, excepted the problem disk. There are only empty fields.

I opend with a hexeditor the vdi file and it looks similar like a healthy one i have tested.

i would belief, that some kind of partition table is left and i hope the files are still there.

i have a backup (~1 month old) but in the backup is a very important file missing. it has not existed at the time when i made the backup.

I read several threads here and i saw it could help if i read with dd the first blocks or a specified nr of bytes from the start of the healthy VDI file and write them to the corrupted one.

I know that a hard disk has a partition table (i think its in the mbr) and i know a filesystem has an index of the inodes and the files accociated with it. And i think then comes the files stored in the filessystem.

How can i determine how much i must read from the healty disk and write to the bad disk?

I dont know if its needed:
Linux name 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

I hope, someone can help me.

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

Re: VDI corrupted

Post by mpack »

Use your hex editor to save the first 2101248 bytes of the VDI file to a separate file. Zip up that partial VDI file and attach the zip here.

Please also tell me the current size of the corrupted VDI file, in bytes.

Also, the logical size of the drive, if you know it.
itsme
Posts: 4
Joined: 22. Feb 2017, 15:27

Re: VDI corrupted

Post by itsme »

mpack wrote:Use your hex editor to save the first 2101248 bytes of the VDI file to a separate file. Zip up that partial VDI file and attach the zip here.

Please also tell me the current size of the corrupted VDI file, in bytes.

Also, the logical size of the drive, if you know it.
Hello!

I have a good backup (where the needed file does not exist) and a bad disk with the needed file). So we can use the first Bytes of the backup for the restore i guess?

i created a dump from both disk and zipped them.

Size of corrupted VDI file in Bytes is 161289863168

I bootet the backup, thats the output of "fdisk -l"

Code: Select all

root@PrivateSys:~# fdisk -l

Disk /dev/sda: 161.1 GB, 161061273600 bytes
255 heads, 63 sectors/track, 19581 cylinders, total 314572800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00065da7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758   314570751   157034497    5  Extended
/dev/sda5          501760   314570751   157034496   83  Linux

Disk /dev/mapper/sda5_crypt: 160.8 GB, 160801226752 bytes
255 heads, 63 sectors/track, 19549 cylinders, total 314064896 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/sda5_crypt doesn't contain a valid partition table

Disk /dev/mapper/system-root: 156.5 GB, 156502065152 bytes
255 heads, 63 sectors/track, 19026 cylinders, total 305668096 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/system-root doesn't contain a valid partition table

Disk /dev/mapper/system-swap_1: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders, total 8388608 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/system-swap_1 doesn't contain a valid partition table
root@PrivateSys:~# 
I hope this answers all you asked for!

Thank you very much mpack!

Best regards,
Oliver
Attachments
2101248_of_healthy_disk.zip
(236.21 KiB) Downloaded 8 times
2101248_of_corrupted_disk.zip
(241.48 KiB) Downloaded 8 times
itsme
Posts: 4
Joined: 22. Feb 2017, 15:27

Re: VDI corrupted

Post by itsme »

cool! its running.

i replaced with the healthy dump and it has booted now :)

Thanks for the hint with the 2101248 bytes!

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

Re: VDI corrupted

Post by mpack »

That was not the suggestion at all. What you did replaced the entire header and block map, which resets the VDI back to the old backup state, plus the header has not been tailored to match the disk image. The file you want may or may not be retrievable. I hope you have a backup of the corrupted drive before you did this.

I had a quick look at the corrupted header. There is a mismatch between the image size and the blockmap. The blockmap has been initialized for an image containing a maximum of 153600x1MB blocks. Your actual image is 153816 blocks, so the image is already 216MB larger than its maximum size - which obviously should not have happened, and I don't understand how it did. My best guess is that VirtualBox has a bug concerning queued writes which applies when you have filled a dynamic drive to capacity.

I've also dug into what would be required to repair the damage properly: it would be difficult, as the blockmap contains many nonsensical values. So, I'll park that unless I hear from you again.
itsme
Posts: 4
Joined: 22. Feb 2017, 15:27

Re: VDI corrupted

Post by itsme »

Hello!

Yes i had a good backup, but it was old. But i could use the first bytes of it for the damaged one.

I think you are right, it happend again. My disk (VDI) was full and i run out of size. It seems that virtualbox still writes to the disk and demage it in such a case, even if its full.

I only wanted to inform you about this.

Best regards,
Oliver
Post Reply