Virtual disk images (.vdi files) tend to grow over time, especially with windows guest systems, and may quickly consume all your disk space on the host system.
This post shows the required steps to free up the unused space. It worked for me with Sun/Oracle VirtualBox versions of 3.1.6 and above.
For a Windows guest system
- Start a Defragmentation (right-click disk icon, select properties->Tools tab-> Defragment now…)
- Download Sdelete (about 47kb) into your guest.
Wait for the defragmentation to complete. - Fill the free space of your vdi disk image with zeros executing
sdelete -c
from a DOS command line.
This may take a lot of time (30min for a 20GB disk on my system).
Don’t use the guest system during the process - Shut down your windows guest system.
- Make a backup of your .vdi file.
- On your HOST system, execute the following command in a DOS/terminal window:
VBoxManage modifyhd diskname.vdi> --compact
The VBoxManage tool is part of the VirtualBox standard distribution.
Warning! DO NOT DO THIS if you virtual disk is longer that the physical! SDelete will blow up you physical disk as it requires the full size of disk to perform its process. Another way to do this "shrink" thing, is to make a clone of the virtual disk with Acronis software to another virtual machine disk; then use only the cloned disk. By this way you do not take the unused / deleted spaces of the disk.
No comments:
Post a Comment