virtualbox

Compressing a Windows Guest Running In VirtualBox

VirtualBox is my favorite go to quick virtualization tool. Its versatile and can run on many host platforms as well as support many guest platforms (windows/linux/aix/solaris..). For those who can’t afford licensing for a VMware cluster, standing VirtualBox up on a beefy server and partitioning out its proc/mem is a perfect solution for a sandbox.

Nonetheless the largest issues I, as well as many of you, face are the use of dynamically allocated disk images. Most users go for the dynamically expanding images in VirtualBox as they do not want to limit themselves to a small virtual disk size and at the same time do not want to waste disk space on their host while the guest doesn’t actually need it.

VirtualBox has some built-in functionality to deal with this. If you have a guest windows operating system, here are some quick steps to free up some disk:

1) Start the windows guest virtual machine and delete any unnecessary files
–> use system tools, disk cleanup if its not a windows server
*** if windows server, my favorite tool is GetFolderSize
2) Next step is to run disk defrag of the windows guest virtual machine
–> use system tools, disk defrag
3) Clean free space on the disk of the windows guest virtual machine
–> Empty the recycle bin
–> can rerun the disk cleanup from step 1. Doesn’t hurt any
4) Shutdown the windows guest virtual machine
5) Using the VBoxManage utility to compact the windows guest virtual machine image
–> To compact the Windows guest image, use the VirtualBox VBoxManage utility. Assuming a Windows host, use the following command at the DOS prompt:

VBoxManage modifyhd –compact “[drive]:\[path_to_image_file]\[name_of_image_file].vdi”
Ensure that you replace the items in square brackets with your parameters.

C:\> path C:\Program Files\Oracle\VirtualBox
C:\> VBoxManage modifyhd –compact “C:\mwlab01_VMs\mwlab01-win7-01.vdi”
Once the VirtualBox VBoxManage utility is running you will see progress indicators in 10% increments starting from 0% to 100%. And once the process is complete, you should have a smaller disk image file.

This process is thoroughly documented and as always I recommend reading the documentation.

When crunched for disk space locally or on your san/nas this is a quick non-intrusive method to clean things up.

Leave a Reply

Your email address will not be published.