Page 1 of 1
.vdi size increases unnecessarily
Posted: 17. Sep 2012, 10:57
by varun.chitre15
Hello all
I have setup-ed Ubuntu 11.04 on my virtual box. I am facing very weird and serious problem
The size of virtual disk image is just increasing day by day. And most serious problem is if I delete files in my Ubuntu, the size doesn't decrease
I nearly deleted 4gb of files in but no decrease in .vdi size
Whats wrong??
Pls I need urgent assistance, I have hosted the vdi on C drive and C drive is running out of space
Day before yesterday the size of vdi was 10.9 GB, yesterday it became 12.5 and today it is 13.6GB
Pls help me, I tried cleaning ubuntu using Bleachbit but still no luck
No idea why the .vdi is swelling

Re: .vdi size increases unnecessarily
Posted: 17. Sep 2012, 11:00
by mpack
Why would you expect the host file size to decrease if you delete files inside the guest?
Dynamic VDIs grow every time a sector is written to for the first time. They never shrink. The size generally settles down after a few days of use, as the chance of hitting a new sector decreases. If it keeps increasing then perhaps some guest process is writing to a lot of disk sectors, e.g. a background defragmenter. Look out for unnecessary guest processes, especially disk related ones for defragmenting or indexing.
Bleachbit is a good example of an unnecessary (though not background) process that will write to a lot of disk sectors and hence make your VDI grow larger. I'm not sure why you thought the opposite might be the case.
A host tool such as CloneVDI can be used to shrink VDI files, though that involves cloning the drive, and I do wonder if you have room. Frankly, if 13GB makes you worry about running out of host disk space, then you really don't have enough disk space to run VMs. I suggest you get yourself a humungous second drive - that's what I did.
Re: .vdi size increases unnecessarily
Posted: 17. Sep 2012, 11:06
by varun.chitre15
Thanks for the prompt reply
Yes you are right.
I am using Ubuntu to compile Android linux kernel from kernel source.
During compilation nearly 2-3 GB of object files are generated. But I delete them as soon as compilation completes
And everyday I compile kernel 3-4 times by making some changes
How would I force decrease it? because it has become a problem to me, I only need 4 GB at the max but why vdi took 13.5GB? What could be solution for that?
Re: .vdi size increases unnecessarily
Posted: 17. Sep 2012, 11:17
by varun.chitre15
Ok then I think the object files created during compilation are written to new sectors. Then does it mean swelling of vdi is unstoppable? Then in notime it will occupy my full hard disk
There should be a solution for this. Anyone?
Re: .vdi size increases unnecessarily
Posted: 17. Sep 2012, 11:23
by mpack
It is unlikely (to say the least) that a compiler actively seeks out unused sectors to write files to. It is possible that what you are seeing is a byproduct of the Linux filesystems strategy for avoiding file fragmentation.
As I said above, the rate of growth should slow down, assuming your usage patterns are consistent. You could shrink the VDI using
CloneVDI, but that is kind of pointless if the conditions that caused the growth are continually repeated. The only way to permanently constrain growth would be to run
gparted and shrink the internal partition to a desired maximum size, then clone with CloneVDI to empty out the unpartitioned space. Be aware however that if you starve a guest OS of disk space then files will be fragmented and performance will suffer.
But the only
real cure for your problem is more disk space. And btw: I don't recommend using external drives except for backups. Too much danger of unplugging, and performance is generally less.
Re: .vdi size increases unnecessarily
Posted: 17. Sep 2012, 12:05
by varun.chitre15
Thanks for the reply
I used CloneVDI, and to my surprise the cloned vdi size was 6.3GB
How was that?
Can I replace original one with this? I have no problem doing this periodically. But what risks are involved to lose data in the clone? Thanks
Your tool is great!
Re: .vdi size increases unnecessarily
Posted: 17. Sep 2012, 13:27
by mpack
CloneVDI compaction was probably so effective because it eliminated all those sectors you added with bleachbit etc.
The clone can replace the original provided you have used the "Keep UUID" option, and provided that you never use snapshots in the VM (anyway with your lack of disk space the last thing you need is snapshots taking up space too). And of course VirtualBox must be shut down while you do this.
Provided those conditions are true then CloneVDI has a trick you can use: use the same path and filename for source and destination, and CloneVDI will do the filename juggling / renaming for you. All you have to do sometime later is delete the old vdi after testing that the new one works.
As to risks - they are slight to none: CloneVDI never modifies the original, so you always have that to fall back on.
Re: .vdi size increases unnecessarily
Posted: 17. Sep 2012, 21:40
by Rui Baptista
One easy way to keep your vdi tight is to build a stable release with all your essentials and make a snapshot.
Then you can do your stuff and go back to the snapshot, and do it again and again, without wasting space.
Re: .vdi size increases unnecessarily
Posted: 18. Sep 2012, 11:16
by mpack
The use of snapshots entails so many risks and disadvantages that I never recommend their use under any circumstances. Even a momentary use causes the xml (.vbox) settings to be modified, opening the door for new error modes. If there is any danger of running out of disk space than snapshots are the last thing you should consider.