Will zero filling increase the size of virtualbox dynamic disk image
I have been mostly using fixed-sized disk images for Oracle virtualbox, but I am considering switching to dynamic disk images as I heard that dynamic images are similar in performance to fixed-size images except when expanding.
One operation I do a lot though is to zero-fill a fixed-size disk image before backing it up using a zip program (to reduce the size of the zip archive). My question is, when I zero-fill a dynamic disk, will the disk size increase to its maximum declared value? (For my specific case, I am using sdelete -z
on windows partitions.)
One additional question is, is there a way to zero-fill partitions without increasing the disk size?
Thanks.
-- EDIT --
To clarify, the reason I ask is that I want to keep the size of compressed virtualbox images at a minimum. Zero-filling a fixed sized image does the job as the zero-filled portion contributes almost nothing to the compressed image. However, if I switch to dynamic disk, zero-filling seems to defeat the purpose of using dynamically sized images.
The second part of my question is really asking if there is a better alternative than zero-filling that can remove unused sectors without expanding the disk size.
I have just tested it (using sdelete -z
in a VM) and zero filling the disk will not appreciably increase the size of the dynamic disk image. Virtualbox is smart enough to recognise that when you are writing zeros to an already empty block the disk does not need to have the block written again.
But even if it did then that's not too bad, because zero filling the disk will also do is allow you to compact it again using the Virtualbox Tools in your host: How to compact VirtualBox's VDI file size?
When I zero filled my VM it took the image size up from ~14.5GB to ~15.5GB but did not completely allocate all the disk space, which would have been approximately 48GB.
In fact zero filling the disk (via sdelete -z
) will allow you to properly free up any space that was written but has since been freed up by your VM operating system, then you can run the command VBoxManage.exe modifyhd c:\path\to\thedisk.vdi --compact
on your host machine to properly compact the dynamic disk image back down to its minimum size.