Windows 10: Reducing the disk footprint

 

An Overview

A while back, a blog post at https://blogs.windows.com/bloggingwindows/2015/03/16/how-windows-10-achieves-its-compact-footprint/ talked about the things that Windows 10 does differently in order to reduce the total disk footprint. 

image

Part of these savings come from the fact that Windows 10 systems no longer need or use recovery images, so you can get back 4GB from that.  Instead of using a recovery image, the reset process used by Windows 10 reconstructs the operating system using the components in the \Windows\winsxs folder structure.  (This also has the added benefit that the OS is almost fully patched after the reset.  All but the most recent 30 days of components updates are automatically used.  That’s by choice: you might be resetting to deal with a problem with components that were upgraded in the last month, which would be counter-productive.)

The remaining disk space benefit comes from an optional compression mechanism called Compact OS.  This works by taking many of the OS files and putting them into a single hidden container (basically a WIM file), where they are compressed and all the disk sector waste is eliminated. 

See https://msdn.microsoft.com/en-us/library/windows/hardware/dn940129%28v=vs.85%29.aspx for more information about Compact OS.

This is an evolution from the WIMBoot capabilities provided in Windows 8.1.  It’s easier to set up and deploy, and can even be done after the OS has been installed. 

WIMBoot with Windows 8.1:  Revisited

WIMBoot can still be used with Windows 8.1.  If you want to do that, it is easier than it used to be because all the needed pieces are included in the Windows PE images provided in the ADK for Windows 10.  So the steps to do this using MDT are easier:

  • Copy the LTIApplyWIMBoot.wsf script from my WIMBoot blog post into your MDT deployment share.

  • Modify your task sequence to add a condition to the existing “Install Operating System” to cause it to be skipped (don’t disable it, as that affects the wizard), e.g. task sequence variable “NOTEXIST” equals “NOVALUE”.

  • Add a new “Run command line” script after the “Install Operating System” step and configure it to run:

    CSCRIPT.EXE %ScriptRoot%\LTIApplyWIMBoot.wsf

Then you’re ready to deploy.

Compact OS with Windows 10

With Windows 10, the compact OS setup does not require any special images or additional partitions.  It doesn’t use a WIM file, and the compressed files are stored on the normal OS volume.  So there are no special steps needed to configure a machine for compact OS.  You just need to specify that this should be enabled.  There are different ways to do this, depending on how you are deploying (or have deployed) Windows 10.  These are covered in the following sections.

Compact OS manually

If you want to try the new compact OS capability, you can do this directly from Windows PE.  Here are the steps:

  1. Format and partition the disk as required.

  2. Apply the OS image to an NTFS partition using DISM:

    DISM.EXE /Apply-Image /ImageFile:INSTALL.WIM /Index:1 /ApplyDir:C:\ /Compact:ON

  3. Run BCDBOOT C:\WINDOWS to set up the OS to boot.

  4. Reboot.

Compact OS with MDT 2013 Update 1

With MDT 2013 Update 1, MDT moved from using ImageX.exe to apply images to instead use DISM.EXE.  That’s convenient, because it makes it easy to tweak MDT to add the /Compact:ON switch.  To do this, open up LTIApply.wsf in Notepad and find these lines and add the three highlighted ones:

' Apply the image

sCmd = " /Apply-Image /ImageFile:""" & sImagePath & """"
If sRWMPath <> "" then
sCmd = sCmd & " /SWMFile:""" & sRWMPath & """"
End if
If sSWMPath <> "" then
sCmd = sCmd & " /SWMFile:""" & sSWMPath & """"
End if
sCmd = sCmd & " /Index:" & sImageIndex & " /ApplyDir:" & sDestinationDrive
If UCase(oEnvironment.Item("OSDCompact")) = “TRUE” then
sCmd = sCmd & " /Compact:ON"
End if

With those new lines in place, any time the “OSDCompact” variable is set to TRUE, it will add the DISM command line option to set up the compact OS while the image is being applied.  (You might want to set this variable conditionally, e.g. only on systems with 32GB or smaller hard drives.)

Compact OS with ConfigMgr

In theory, you can do something similar with ConfigMgr, replacing the built-in “Apply Operating System” step with a script that does the same thing.  But that’s quite a bit of work, for a couple of reasons:

  • The script needs to set the same variables that the built-in step does, otherwise the task sequence will fail.
  • The script can’t be used from a “Run command line” step because you can’t use an OS image package with such a step.  To work around this, you need to create a new custom step and add that to the task sequence editor via a MOF file.  (You can cheat and reuse the “Apply Operating System” step’s UI, since the script needs the same inputs anyway.  That just ends up looking rather weird.)

Fortunately, there is an easier way.  You can allow the OS to be deployed without initially configuring it for compact OS, then convert it afterwards, as part of the task sequence.  This will temporarily take up more disk space (about 3GB on a 64-bit system), but I’ll take that for the simplicity of it.

To make this work, set up a new “Run command line” step somewhere in the “State Restore” phase of an MDT-generated ConfigMgr task sequence for Windows 10.  For this step, specify the following command line:

COMPACT.EXE /CompactOS:always

This uses one of the new compact OS switches that have been added to COMPACT.EXE in Windows 10.  This will take 15-20 minutes to compact the OS files, but that’s all there is to it.

Compact OS manually, take 2

You can probably guess from the ConfigMgr section above that the exact same COMPACT.EXE command line can be used on any Windows 10 system to enable (compress) or disable (decompress) compact OS.  Feel free to try it on your system:

COMPACT.EXE /CompactOS:always

knowing you can turn it back off again with:

COMPACT.EXE /CompactOS:never