Jaa


Trim your wim in only three simple steps

The smallest possible wim sizes can be achieved by following these steps:

  1. Install only the optional components (OCs) you need
  2. Use peimg /prep to remove the extra OCs you didn't install
  3. Use imagex /export to recover the space left behind by the deleted OCs

The x86 en-us WinPE 2.0 winpe.wim packaged with the Windows AIK weighs in at about 160MB.  However, the WinPE boot.wim on the Vista DVD takes up only 122MB, and that includes the setup application.  The trick to getting it so small is to understand what takes up so much space in the first place and how you can use peimg.exe and imagex.exe to remove it.

The winpe.wim from the WAIK contains not only the base WinPE image, but also all the optional components.  Initially, these OCs are in a "staged" state: they are ready to install, but aren't usable until you use peimg /install to install the ones you need.  It's very rare that you will require all the OCs in a single image, especially all the font support OCs.  Installing only the ones you need rather than the whole set leaves a great opportunity for reducing the size of the image by getting rid of the leftovers.

Peimg can remove the remaining staged OCs from an image with its '/prep' command.  This safely deletes the part of the image that contains the staged OCs as well as the information required for servicing the image.  Running 'prep' is irreversible, so I always keep an unprepped copy of my image just in case I need to apply a hotfix to it or change my mind about what OCs I need later.

If you followed the common pattern of mount-customize-prep-unmount, you'll notice that the wim is not actually much smaller (it may even be larger).  The wim filter driver doesn't actually reclaim the space when files are deleted, it just marks it.  To actually see the benefits of prep, you have to use imagex /export to produce a new wim with all the space reclaimed.  Make sure you add the '/boot' flag so the new wim is bootable.

At the extreme of installing absolutely no OCs, this method produces a lean 97MB wim, an easy fit for a 128MB USB key drive.

How much bloat does each OC add?  I installed only one OC into a number of different images and subtracted the baseline above:

OC Size (MB)
Scripting  0.9
XML  1.2
HTA  6.1
WMI  8.0
MDAC  10.2

Hope you found this useful!  Next: peimg.exe tips and tricks, including a script to make /inf recursive.

Comments