Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a VDI file using VirtualBox and need to upload it with compression for other to access. The more I use the virtual machine, the less the compression happens. There is not much of difference in the disk usage between compressions, but the compression ratio is deteriorating over time.

What's the reason for this, and is there any workaround to get a constant compression irrespective of the usage of the virtual machine?

share|improve this question
Clearly the entropy is increasing. – Dan D. Jul 5 '13 at 7:51
up vote 5 down vote accepted

With use comes fragmentation which makes compression harder, so one thing you can try is to defrag before taking the image. If you can find a utility that would clear unused disk space (i.e. write zeros on it, rather than old unused data) that would also help, possibly even more than defragmentation, as you wont be compressing unused data (such utilities are sometimes used for permanent deletion of data). Even so, it is likely that compression will still suffer.

share|improve this answer
+1 - Dedragging and compacting should help immensely. There may be OS specific actions that can be taken too, like mounting most partitions read only for *nix systems. – afrazier Jul 7 '13 at 12:47

The size of an active VM will always grow and may require periodical shrinking.
This is mostly because deleted files are not as well compressed as the original empty disk space.

See this article for detailed instructions on how to shrink a VM :

How To Shrink Your Virtualbox VM And Free Up Space For Your Hard Disk.

share|improve this answer
The size of the actual remains the same because I have chosen fixed size VM. The compression ratio becomes worse over time. The url mentioned doesn't help for this problem. – Praveen Sripati Jul 7 '13 at 15:39
The compression ratio only becomes worse because the data is less compressible. When a file is deleted, it is deleted from the folder meta-data but its blocks are left on the disk. So although the disk seems to contain the same amount of used space, compression is still required of the unused space, so that the total size of the compressed disk is larger. Setting all unused blocks to zero improves compression because repeated data compresses the best. Defragmentation (if done right) will consolidate all these zero blocks into one contiguous chunk that will compress even better. – harrymc Jul 10 '13 at 6:46

You must log in to answer this question.

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