When using VirtualBox, the size of VM expands over time. In case of running out of hard disk space, I would like to shrink the VM to free up unused space.
VM Guest: WinXP
Step 1. Open VM Guest and perform a hard disk defragmentation (Disk Defragmenter).
Step 2. Execute SDelete to zero the free space.
Although the VirtualBox manual says that use sdelete -c to zero the free space, I found that execute sdelete -z is better?
Step 3. Shutdown VM and back to the Host machine.
Step 4. Execute
VBoxManage modifyhd [vm filename.vdi] --compact
• The vm filename could be the base images or snapshots.
• Currently this command only supports VDI format.
Step 5. Done.