I've accidentally expanded a dynamically allocated VDI image to ~150TB instead of ~150GB using VBoxManage modifyhd (a lesson to learn: [--resize <megabytes>|--resizebyte <bytes>])

Now, when I'm booting the virtual machine, I get the following warning:

The medium '/home/bbalint/VirtualBox VMs/wii/wii.vdi' has a logical size of 143TB but the file system the medium is located on can only handle files up to 7TB in theory.

To fix my mistake, I tried to resize the VDI again, but now I get the following error:

$ VBoxManage modifyhd {d013c1f5-3f1f-4918-a079-ee27f4b398a3} --resize 150000
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage: error: Resize hard disk operation for this format is not implemented yet!

This is strange, since I did not change any other parameters of the image besides the size:

$ VBoxManage showhdinfo {d013c1f5-3f1f-4918-a079-ee27f4b398a3}
UUID:           d013c1f5-3f1f-4918-a079-ee27f4b398a3
Parent UUID:    base
State:          locked write
Type:           normal (base)
Location:       /home/[...]/VirtualBox VMs/wii/wii.vdi
Storage format: VDI
Format variant: dynamic default
Capacity:       150000000 MBytes
Size on disk:   64526 MBytes
In use by VMs:  wii (UUID: 5810c0ba-4776-48d7-807f-1116295688a0)

How can I fix this?

  • Considering Vbox has a problem shrinking virtual machines in the first place I understand how you do this. You are out of luck. I hope you have a backup of the file before you expanded the HDD. This cannot be done with virtual box. – Ramhound Feb 18 '15 at 11:53
  • I think I've read about good ways to copy everything in one vdi to another... maybe to a different format other than vdi that can do expand/shrink. Strange how the expand works but there's no shrink, despite the file being virtually the same size – Xen2050 Feb 18 '15 at 12:16

I have done the same mistake :(

This is not a direct solution but at least I have been able to recover my data using a method I found here.

Essentially you use nbd and qemu to create a /dev/nbdx device

sudo modprobe nbd max_part=16
sudo qemu-nbd -c /dev/nbd0 bad.vdi

Then I created a new VDI with the correct size:

VBoxManage createhd --filename new.vdi --size 15000 --format VDI

I then used the same nbd and qemu method on it: sudo qemu-nbd -c /dev/nbd1 new.vdi, and then cloned the partition (I used gparted: sudo gparted /dev/nbd0 /dev/nbd1).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.