1

I've created VM with Kubuntu. I didn't know how much space am I going to need so I randomly typed 2TB dynamically allocated. However now I need to make this VM downloadable so it needs to be as compact as possible. In fact there's only 8gb space taken (there was more before cleaning up). I'd like to shrink it but the problem is I actually don't have 2TB space on my drive so I can't create huge zero file of disk size. What can i do?

1 Answer 1

3

There is no need to actually have the 2TB.

(Note: I only know the windows commands, you need to find the respective commands for your OS)

  1. Defrag the VB (run DEFRAG /D C: inside it)
  2. use SDELETE inside the VB (and this will not increase the physical file size - VB is clever enough to realize that a block of all zero is just that)
  3. Use VBmanage outside the Vb to clone the VDI into a new one (which will be smaller)
  4. de-attach the old and then attach the new smaller VDI to your VB.

I did that just last week with a 2 TB VDI, and it never was any issue - it is ~40 GB physical size and resides on a SSD of 128 GB; worked perfectly, even the cloning afterwards.

2
  • Indeed VBox doesn't increase file size if you write zeros. I didn't know that. Thanks
    – Lapsio
    Jul 16, 2016 at 21:26
  • Besides there's --compact option for VBoxManage which shrinks image without necessity of cloning it.
    – Lapsio
    Jul 19, 2016 at 16:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .