Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers

up vote 5 down vote accepted
+150

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  
+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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.