0

I created a dynamically growing VirtualBox VDI and wanted to shrink its size after a long time of use. I briefly searched for the solution and it seems that the steps to do so are:

  1. Zero the free space (by creating a large file filled with zeros).
  2. Run vboxmanage modifyhd <VDI> --compact.

My problem here is that the VDI size (seen in the guest) is much larger than that of the partition where the VDI resides (e.g. 2TB VDI on a 320GB partition). Is the above method still doable in this case? If not, are there any other possible solutions?

Also, if VDI fails to support such an allocation scheme, will any other virtual disk formats do?

  • the vboxmanage tool cannot shrink virtual box's virtual hdds. You would have to convert the file, use a different tool, then convert it back. – Ramhound May 8 '15 at 11:04
  • Is there any tool which can give me a shrinked VDI without expanding it to its maximum size? – Cyker May 9 '15 at 3:34
0

The vboxmanage modifyhd (or modifymedium on more recent vbox versions) can compact the vdi file. A dinamic disk can be created as you mention like 2TB in a 350Gb partition, this kind of disk increases its size when you use more space in the virtual machine until there is no available space on the physical disk. Performing a compact doesn't get the full size of the vdi, you need to follow this process to compact the vdi file as the size you can see on the guest.

How to compact VirtualBox's VDI file size?

  • BTW, filling the free space with zero doesn't mean that the entire virtual disk is going to be filled, you only are setting that space to 0 to mark it as a no used space. – Genaro Morales Jun 22 '17 at 23:29
-1

I don't think that the VDI size itself can be bigger than the partition size where it resides. Do you mean that the 2TB is the dynamic size allocated to the VDI?

If yes, then i think you still can do it. But, you miss one step after creating a large zero-fill file. You need to delete it, and then you just power off the VM and then compact it.

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.