Page 1 of 1

Zeroing out free space without expanding the virtual image

Posted: 20. Aug 2011, 22:18
by Melab
I've noticed and learned that tools like SDelete, nullfile, and zerofree will expand the virtual machine's disk image because they fill everything up with zeros (that is not used space, of course). I am very low on memory. Is there a way I could zero out the space inside without it expanding the image?

Re: Zeroing out free space without expanding the virtual image

Posted: 20. Aug 2011, 22:23
by stefan.becker
http://wiki.winehq.org/MacOSX

http://forums.virtualbox.org/viewtopic.php?f=6&t=22422

Dont know if its work on mac. But on a linux host this windows program with wine is the best solution for cloning and shrinking images.

Re: Zeroing out free space without expanding the virtual image

Posted: 21. Aug 2011, 01:15
by Melab
Can

Code: Select all

VBoxManage modifyhd <VM>.vdi --compact
be applied to snapshots?

Re: Zeroing out free space without expanding the virtual image

Posted: 21. Aug 2011, 08:26
by BillG
Melab wrote:I've noticed and learned that tools like SDelete, nullfile, and zerofree will expand the virtual machine's disk image because they fill everything up with zeros (that is not used space, of course). I am very low on memory. Is there a way I could zero out the space inside without it expanding the image?
I don't follow what you are driving at. Running those tools does not expand the disk image (or reduce it). The purpose of the tool is to convert unused space to zeros so that a disk compacter can reduce the space. A compacter cannot reduce the size of virtual hard disk file (by removing the unused space) until it is zeroed. If a block has been zeroed, it is not copied, so the size of the file is reduced.

Re: Zeroing out free space without expanding the virtual image

Posted: 21. Aug 2011, 11:06
by mpack
FYI: zeroing unused space does not make the disk smaller, it is now just full of zero bytes. As Bill says you would typically follow this by compacting, as both VBoxManage and CloneVDI will recognize disk blocks which are entirely filled with zeros, and replace them with stubs that don't need host space.

Unfortunately, none of the compaction techniques work on snapshots. If you want to recover disk space you must stop using snapshots.

And incidentally, CloneVDI does work (according to several Mac users) under Wine/WineBottler on a Mac. Discussion here. With CloneVDI you do not need to run sdelete, as it understands the guest filesystem and recovers unused space directly.

Re: Zeroing out free space without expanding the virtual image

Posted: 21. Aug 2011, 11:23
by stefan.becker
And CloneVDI is 10 times faster than the sdelete/Compact Method.