Goal – shrink my VDI using VirtualBox-provided tools
Important note (this will come into play later): I have VERY fast home-grown ZFS-based NAS/SAN that stores my VDI (and most other) files that I use on a regular basis. In most cases, this proves to be faster than running virtual machines off of my local disk.
I wanted to compact my Sun (now Oracle) VirtualBox vdi file. The vdi file was created with version 3.2.12r68302 of VirtualBox, and was a clean, patched base install of Windows 7 that I wanted to compact as much as possible. After reviewing the user’s manual that comes with the product (C:Program FilesOracleVirtualBoxdocUserManual.pdf), page 99 gave me the command line to use (vboxmanage.exe modifyhd –compact file.vdi), and page 116 references the sdelete tool from Microsoft required to zero out blank space. After deleting unnecessary files, deleting system restore points, emptying recycle bin, etc., I ran the sdelete tool (which took about 2 hours), then shut the machine down. So far, so good. Now it was time to run the “vboxmanage.exe modifyhd –compact” command, which presented a problem that most people probably won’t run into.