Saturday, January 28, 2012

VirtualBox compact vdi files


Many time running an operating system on a VM, installing/deinstalling software, copying and removing data... the size of the vdi disks increase too much. But if we check the storage on guest system, the difference between vdi file and used space is huge. It is the moment to compact the vdi file.

In my case I have a Windows XP guest running on Ubuntu 10.04 x86_64 host. The size of the vdi fileis 84GB. Bellow the process to compact:

1. GUEST: Defragment guest disk on VM OS.
2. GUEST: Execute SDELETE, to release unallocated space of deleted files, then VBoxManage compactor detect this sectors are unallocated and can free them. Wait... depends on size of vdi file.
C:\> sdelete -z -c C:\
3. Stop VM
2. HOST: Execute:
VBoxManage modifyhd WindowsXP.vdi --compact

Performing these actions my vdi file goes from 84GB to 40GB.

No comments:

Post a Comment