Page 1 of 1

[SOLVED] Does Virtualbox automatically resize VHD files?

Posted: 30. Aug 2011, 08:49
by trusktr
I was just curious. I'm implanting a Windows VHD into Virtualbox, which is about 67gb, but some of that is empty space. Can I trim down the VHD to encompass only the used space, and have Virtualbox auto-resize the VHD? Is this automatic already, or do I need to set it up?

Re: Does Virtualbox automatically resize VHD files?

Posted: 30. Aug 2011, 13:10
by mpack
Does it need to remain in VHD format? If not, then clone it using CloneVDI (see sticky in "Windows Hosts"), selecting the "Compact" option. That will (a) get rid of all the unused space, (b) convert it to VDI format, which is better for VirtualBox.

Re: Does Virtualbox automatically resize VHD files?

Posted: 30. Aug 2011, 23:40
by trusktr
Ok cool. I'll try that! Thanks. Virtualbox will autmatically keep the VDI at the minimum size with no empty space? Do VDI files that contain MS Windows need to be defragmented?

Re: Does Virtualbox automatically resize VHD files?

Posted: 31. Aug 2011, 12:42
by mpack
No, VirtualBox will not keep releasing the unused disk space: it knows nothing about guest filesystems and hence has no way to know if disk space is still used or not. It knows only that disk space was used in the past because it was written to. If you want to keep the drive compacted you'll have to run CloneVDI on it again, periodically.

On the defragmentation question: the host container format (i.e. VDI), doesn't change how the guest OS organises drive space. So yes, like all Windows drives, it will benefit from running a good defragmenter every once in a blue moon.

Re: Does Virtualbox automatically resize VHD files?

Posted: 9. Sep 2011, 04:32
by trusktr
Ok, thanks! So VDIs are autmoatically resizing, just to be sure, right?

Re: Does Virtualbox automatically resize VHD files?

Posted: 9. Sep 2011, 12:27
by mpack
All of the dynamic image types (VDI, VHD, VMDK) essentially work the same way in VirtualBox (and other VM platforms too): they get larger as data is added. They never get smaller unless you intervene manually, by running a compact tool. VDI is preferable because it's the native image format, supported by all drive functions, and it is less prone to corruption than a VHD.