Reduce VirtualBox’s VDI Size

  1. Run defrag in the guest (Windows only)
  2. Nullify free space:
    With a Linux Guest run this:

    sudo dd if=/dev/zero of=/bigemptyfile bs=4096k
    sudo rm -rf /bigemptyfile

    With a Windows Guest, download SDelete from Sysinternals and run this:

    sdelete –z
  3. Shutdown the guest VM
  4. Now run VBoxManage’s modifyhd command with the --compact option:
    With a Linux Host run this:

    vboxmanage modifyhd /path/to/thedisk.vdi --compact

    With a Windows Host run this:

    VBoxManage.exe modifyhd c:\path\to\thedisk.vdi --compact

    With a Mac Host run this:

    VBoxManage modifyhd /path/to/thedisk.vdi --compact

This reduces the vdi size.


Leave a Reply

Your email address will not be published. Required fields are marked *