Shrink/compat a windows guest dynamically allocated NTFS disk image which is in the Virtual box .VDI format to its minimum size.
In order to achieve this, there are a number of programs and steps you need to take;
- Clean up your windows FS
- Defrag your windows guest fs and optimise it into a solid block of data.
- Ensure that all free space on the disk is zero'ed out, so Virtual box can see what is unused. This might increase your VDI file to the maximum size, so make sure you have the free space. Virutal box documentation on the flags to use with sdelete are at present wrong! Dont use -c, use -z.
- Tell Virtual box to compat the VDI disk image
- Boot up your windows guest and uninstall/delete all unwanted programs and files
- Install Ultra Defrag
- In Ultra Defrag, run a Defragment [F6]
- In Ultra Defrag, run a Full Optimization. [Ctrl+F7]
- Download the latest version of sdelete and Extract sdelete zip to c: (or what ever drive your shrinking).
Click Start> Run and type cmd. in the command prompt type;
c:\sdelete.exe -z c:
- Shutdown the windows guest
- Run the following command on the linux host (windows virtual box has a similar command and syntax);
VBoxManage modifyhd /path/to/disk.vdi compact