Reduce the Size of the Component Store in an Offline Windows Image

You can use the Deployment Image Servicing and Management (DISM) tool to mount a Windows image from a WIM, VHD, or VHDX file and modify it.

Analyze and clean up the Component Store (WinSxS folder) in an offline Windows image

To complete the walkthrough, you need the following:

  • A computer running Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2016 Technical Preview, Windows Server 2012 R2, Windows Server 2012, or Windows Server 2008 R2 with the Windows 8.1 version of the Windows ADK tools installed on it.

  • A .wim, .vhd, or .vhdx file of a Windows 10 or Windows Server 2016 Technical Preview image.

Analyze the size of the Component Store in an offline Windows image

  1. Copy a .wim file, a .vhd, or a .vhdx that contains a Windows image, to the local drive. For example, C:\test\images.

  2. Click Start, and type deployment. Right-click Deployment and Imaging Tools Environment and then select Run as administrator.

  3. Create a folder for your mounted image. For example, C:\test\offline.

  4. Run the DISM /Get-ImageInfo command to retrieve the name or index number for the image that you want to update. For example:

    Dism /Get-ImageInfo /ImageFile:C:\test\images\MyImage.wim
    
  5. Mount the Windows image. For example:

    Dism /Mount-Image /ImageFile:C:\test\images\MyImage.wim /Index:1 /MountDir:C:\test\offline
    

    Since WIM files can contain one or more images, you must specify an index or name value. To mount an image from a VHD, you must specify /Index:1.

  6. Analyze the size of the component store. For example:

    Dism /Image:C:\test\offline /Cleanup-Image /AnalyzeComponentStore
    

    To understand the different values provided in the display, see Determine the Actual Size of the WinSxS Folder.

  7. If the component store cleanup was recommended in the displayed report, then you can start cleanup of the image. For example:

    Dism /Image:C:\test\offline /Cleanup-Image /StartComponentCleanup
    
  8. You can reduce the size of the component store further by adding the /ResetBase parameter. For example:

    Dism /Image:C:\test\offline /Cleanup-Image /StartComponentCleanup /ResetBase
    

    Beginning with Windows 10, version 1607, you can specify the /Defer parameter with /Resetbase to defer any long-running cleanup operations to the next automatic maintenance. But we highly recommend you only use /Defer as an option in the factory where DISM /Resetbase requires more than 30 minutes to complete.

    The maintenance task is scheduled to run weekly, with a two-week deadline.  In the first week, the maintenance task will only run during system idle maintenance windows.  If it is unable to complete (for example, the computer is turned off when not in use) then the task scheduler runs more often, and the task may run while the system is not idle.

    To see the performance effects while the task is running, click Start > Run and type the following command:

    Schtasks.exe /Run /I /TN \Microsoft\Windows\Servicing\StartComponentCleanup
    
  9. Commit the changes and unmounts the image in order to save the changes that you’ve made. For example:

    Dism /Unmount-Image /MountDir:C:\test\offline /Commit
    

Manage the Component Store

Clean Up the WinSxS Folder

Determine the Actual Size of the WinSxS Folder

Where Did My Space Go? (blog post)

NTFS Metafiles blog post

How to create and manipulate NTFS junction points

DISM Operating System Package Servicing Command-Line Options