Latest News & Blog

Shrink Virtualbox VDI disk

Shrink windows guest Virtualbox VDI disk

Monday 30 April, 2012



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;

Steps Outlined

  • 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

The Steps

  1. Boot up your windows guest and uninstall/delete all unwanted programs and files
  2. Install Ultra Defrag
  3. In Ultra Defrag, run a Defragment [F6]
  4. In Ultra Defrag, run a Full Optimization. [Ctrl+F7]
  5. Download the latest version of sdelete and Extract sdelete zip to c: (or what ever drive your shrinking).
  6. Click Start> Run and type cmd. in the command prompt type;
    c:\sdelete.exe -z c:
  7. Shutdown the windows guest
  8. Run the following command on the linux host (windows virtual box has a similar command and syntax);
VBoxManage modifyhd /path/to/disk.vdi compact

Written By...

Lee Simpson

Software Engineer, Linux Wizard, proud father of 3 boys