Page 1 of 1

failed to undo a bad resize over vdi image

Posted: 31. Oct 2016, 14:48
by amery
Hi,
by mistake I resized a vdi using --resize <sizeinbytes>

Code: Select all

$ ls -l Windows\ 7-disk1.vdi 
-rw------- 1 amery amery 68605181952 Oct 31 10:39 Windows 7-disk1.vdi
$ file Windows\ 7-disk1.vdi 
Windows 7-disk1.vdi: VirtualBox Disk Image, major 1, minor 1 (<<< Oracle VM VirtualBox Disk Image >>>), 81064793292668928 bytes
but if I try to resize it back to a sane value it even fails to read it.

Code: Select all

$ VBoxManage modifyhd $PWD/Windows\ 7-disk1.vdi --resize 72000 --compact
VBoxManage: error: Could not get the storage format of the medium '/home/.../Windows 7-disk1.vdi' (VERR_NOT_SUPPORTED)
VBoxManage: error: Details: code VBOX_E_IPRT_ERROR (0x80bb0005), component MediumWrap, interface IMedium, callee nsISupports
VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 179 of file VBoxManageDisk.cpp
Any idea how can I correct it?

Thanks in advance.

Re: failed to undo a bad resize over vdi image

Posted: 31. Oct 2016, 15:28
by mpack
Google for "vidma site:forums.virtualbox.org".

Re: failed to undo a bad resize over vdi image

Posted: 31. Oct 2016, 17:45
by amery
mpack wrote:Google for "vidma site:forums.virt....".
Thanks mpack. I tried but:

Code: Select all

Recognized file format:
        Virtual Disk Image (vdi)

ERROR   Insane number of allocated blocks.
ERROR   block size (1048576), block count (0) and disk size (81064793292668928) mismatch.
how bad is it?

Re: failed to undo a bad resize over vdi image

Posted: 31. Oct 2016, 17:47
by amery

Code: Select all

$ vidma Windows\ 7-disk1.vdi 
Recognized file format:
        Virtual Disk Image (vdi)

pre.file_info                    = <<< Oracle VM VirtualBox Disk Image >>>

pre.signature                    = beda107f 3201962111
version                          = 00010001 65537
header.size                      = 00000190 400
header.type                      = 00000001 1 (dynamic)
header.flags                     = 00000000 0
header.offset.bam                = 00100000 1048576
header.offset.data               = 00100000 1048576
header.pchs.cylinders            = 00000000 0
header.pchs.heads                = 00000000 0
header.pchs.sectors              = 00000000 0
header.pchs.sector_size          = 00000200 512
header.dummy                     = 00000000 0
header.disk.size                 = 0120000000000000 81064793292668928
header.disk.blk_size             = 00100000 1048576
header.disk.blk_extra_data       = 00000000 0
header.disk.blk_count            = 00000000 0
header.disk.blk_count_alloc      = 0000ff91 65425
header.uuid.create               = 4f873c80-3bdb-4466-bff8-2049e2306f13
header.uuid.modify               = 9252d753-0478-4a01-83ae-32d49cc2a6e0
header.uuid.linkage              = 00000000-0000-0000-0000-000000000000
header.uuid.parent_modify        = 00000000-0000-0000-0000-000000000000
header.lchs.cylinders            = 4b70024b 1265631819
header.lchs.heads                = 000000ff 255
header.lchs.sectors              = 0000003f 63
header.lchs.sector_size          = 00000200 512

Re: failed to undo a bad resize over vdi image

Posted: 31. Oct 2016, 19:31
by mpack
Vidma is a third party tool - I'm not in a position to support it.

However, given what it says I think we can be pretty sure that the VDI file contents are now garbage. The trouble is that even creating the header to describe such an insane disk size itself produces an insane header: e.g. I calculate it would require 288GB just to hold the block map to describe that image size, and that block map is certainly several orders of magnitude larger than the maximum size VBoxManage could reasonably expect. At best this implies a BugTracker suggestion to limit the disk space to something more reasonable.

You may have to chalk this one up to experience - and take a look at CloneVDI, which can resize a disk without the confusing command line or the inherently risky in-place operation. It will run under Wine on Linux hosts.