How to fix corrupted VHD due to quitting in middle of resizing using VBoxManage

1

I was trying to resize (expand from 20GB to 40GB) a VHD containing a Ubuntu instance using VirtualBox's vboxmanage tool:

./vboxmanage modifyhd path-to-my.vhd --resize 40000

However, it seemed like stuck on 0% (I previously expanded from 10GB to 20GB and it completed instantly) so I force quitted the process. Now, my VHD is corrupted, VirtualBox can't start the instance (telling that VHD is corrupted), I've also tried Windows' Disk Management and it can't attach either (I get "Parameter is incorrect" error).

I also tried resizing it back to the original size (20000):

./vboxmanage modifyhd path-to-my.vhd --resize 20000

But I got:

VBoxManage: error: Error: Attempt to resize the medium from 0.0 MB to 20000.0 MB. Use --resizebyte if this is intended!

I've also tried --resizebyte option:

./vboxmanage modifyhd path-to-my.vhd --resizebyte 20000

VBoxManage: error: Code NS_ERROR_ABORT (0x80004004) - Operation aborted (extended info not available)
VBoxManage: error: Context: "Resize(cbResize, pProgress.asOutParam())" at line 762 of file VBoxManageDisk.cpp
VBoxManage: error: Failed to resize medium!

Is there any way to fix it (e.g. forcing VHD to reporting its size as 20000GB as before, instead of 0 bytes)? The VHD file itself is currently 28.66GB on disk, if it helps.

I know what I did was completely dumb, but is there any way to get my image back?

virtualbox
vhd
asked on Super User Mar 14, 2019 by Can Poyrazoğlu

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0