How to Check the Size and Reclaim Disk Space from WinSxS in Windows 8.1

toggle-button

Windows 7 and 8.x use a folder in the Windows directory called "WinSxS" to store certain system components and a variety of temporary and backup files. At times this folder can grow quite large and a previous tip showed how to free up disk space by reducing the folder’s size in Windows 7. Here are some additional methods that are useful in Windows 8.1.

Determining the size of WinSxS and checking if it needs cleanup

Windows 8 introduced some automatic checking and cleaning of the WinSxS folder but this is done only every 30 days. Windows 8.1 added a command-line tool to check if cleanup is needed.  To see if cleanup is recommended, use this procedure.

  1. Right-click the Windows flag in the lower-left corner of your screen
  2. Select “Command Prompt (Admin)"
  3. In the command prompt window, enter the command:
      Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore

The analysis will proceed. Depending on your system, this may take 5-10 minutes or more. The graphic below shows a typical command prompt window that results.

DISM checking WinSxS

In this example, cleanup is recommended. The analysis also reports various statistics about the contents of WinSxS. One thing to be aware of is that the reported size of the WinSxS folder can be misleading. The folder contains hard links to various files, whose contents are included in the reported size of WinSxS. The files are actually stored in other locations. In the example here, the size of WinSxS is reported to be 6.30 GB. However, 4.75 GB are indicated as “Shared with Windows” and the actual sizes of interest are "Backups and Disabled Features : 1.34 GB" and "Cache and Temporary Data : 201.76 MB".  For further discussion of the actual size of WinSxS, see this Microsoft Technet article.  

Cleaning up WinSxS

If cleanup is recommended, there are several cleanup methods. For component cleanup, do the following:

  1. Right-click the Windows flag in the lower-left corner of your screen
  2. Select “Command Prompt (Admin)
  3. In the command prompt window, enter the command:
      Dism.exe /online /Cleanup-Image /StartComponentCleanup

For even more cleaning, you can remove the backups that allow you to uninstall Windows updates and service packs. Once these are removed, however, you cannot uninstall existing updates. This is the procedure:

  1. Right-click the Windows flag in the lower-left corner of your screen
  2. Select “Command Prompt (Admin)
  3. In the command prompt window, enter the command:
     Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase

Depending on your system, this cleanup procedure can take considerable time. 

Warning

Do not go directly to WinSxS with File Explorer and delete files. Microsoft warns that directly deleting files from WinSxS may severely damage your system so that your PC might not boot or might become impossible to update.

More information

Get your own favorite tip published! Know a neat tech tip or trick? Then why not have it published here and receive full credit? Click here to tell us your tip.


This tips section is maintained by Vic Laurie. Vic runs several websites with Windows how-to's, guides, and tutorials, including a site for learning about Windows and the Internet and another with Windows 7 tips.

Click here for more items like this. Better still, get Tech Tips delivered via your RSS feeder or alternatively, have the RSS feed sent as email direct to your in-box.

Please rate this article: 

Your rating: None
3.954545
Average: 4 (22 votes)
toggle-button

Comments

i think i boneheaded it. i ran the cleanup-image but it seemed to hang at 20% (for around 15 minutes) and couldn't even get into task mgr to end dism, so as boneheads do, i used the power button to just shut down. and of course it screwed things up. now windows updates won't install. i get an error code of 8007371b. and running dism with the restorehealth switch is no help, it errors out also. as a thought i tried system restore to a couple different dates but that didn't help either. i have way too many programs installed so i don't want to do a windows reset if i don't have to. i hope someone here has a better idea

It doesn't work. I'm running Win 7 Pro on a 64 bit machine. My C:/Windows/winsxs folder contains 11.3 GB in 14,330 directories. I'd like to reclaim what I can of the space these folders are using.

I tried your solution for disk cleanup (cleanmgr) for Win 7 but even with every box checked, it only listed 7.85 Mb and none were in the winsxs folder.

I then tried dism.exe and found it to be active in Win 7, but the parsed parameters gave me an error message. Can you help me? Thanks.

I understand this article is for Win 8 which is why I used the link therein to go to the article for Win 7, but as I noted, it still doesn't work. I get error message 87. I didn't post my query in that article because it was a couple of years old.

I understood you to be trying the Dism method. Sorry, if I misunderstood. The method for Windows 7 uses Disk Cleanup and if that is not working for you, more information about what is happening might help. Please post your problem in the forum where help with individual problems can be given.

I won't reply any further. Just want to point out that Win 7 has a dism.exe but it does not have the necessary parsing parameters. I tried Disk Cleanup in both regular and admin modes, but it doesn't even touch the winsxs files and folders. Oh well, I've still 70% of my C: drive free so I'll just live with the 11 gigs of files in my winsxs folder. Thanks anyway.

Yes, dism.exe is in Windows 7 but they added new switches in Windows 8.1. These commands are not available in Windows 7.

You can also do this through disk cleanup in the GUI now easily.

Just open "disk cleanup" by typing it in the search bar.
click to clean-up system files, cleanup will relaunch in admin mode
check "Windows Update Cleanup" and whatever options you want.

Nice article vic.

This one is also good:
http://www.techsupportalert.com/content/reclaim-some-disk-space-which-wi...

Also, i guess WinSxS does contain hard links. The results in your pic say as much. And I read that in the article at Ghacks also. But i also read there that much (all?) of the rest of the system files are actually hard links to this WinSxS. Which is sorta the opposite phenomena. Perhaps C:\Windows\system32 is really just a bunch of hard links.

I checked one file picked at random: C:\Windows\System32\amstream.dll

and it was.

FYI:

I checked by using SysInternals (now part of Microsoft) tool FindLinks: https://technet.microsoft.com/en-us/sysinternals/hh290814

You can also use the built-in fsutil.exe but that requires admin privs. FindLinks does not.

Thanks for your interesting comments, johnvk. I am a molecular spectroscopist, not a computer professional, so my computer science friends may need to correct me but here is my understanding of hard links. Hard links are just addresses in the underlying file structure system so mentioning which folder actually contains a file is probably not what I should have referred to. Both folders C:\Windows\system32 and WinSxS can have a reference to the same file. There may be only one collection on the disk of bits called the file but it will be listed by File Explorer as being present in both folders.

Yes, thanks for reminding me. As i understand it as well, in the absence of multiple hard-links, the single instance of a file is essentially a hard-link from its presence in the directory to its actual contents.

So, yes, saying that the file is truly "in" one dir or another in the presence of multiple hard links might be a misnomer.

My knowledge of this comes from linux, however.

But clearly in your screen grab of the cmd.exe window, it reports windows explorer reported size greater than actual size. I was assuming those were hard links that were "truly elsewhere" but given that we've just discredited that notion, i'm not sure what this report is telling us.

If you have 2 hard links that point to the same file, windows explorer will count its disk space twice. I think i believe that. But which one is the "real" one might be a fictional distinction.

Other insights among the vastly knowledgeable tecchsupportalert.com user base?

Don't get confused - I had to edit this to improve clarity and correct my own errors - file names and hard links are not the same whether in Windows or Linux.

The file name is a real object that points to the location of data. It is fundamental to the file system whereas links are not. See the paragraph below on file systems to make more sense of this point.

A link is a virtual object that points to the same physical location as a file name but is not the actual file name. There are many names for links (aliases, hard links, soft links, symbolic links, etc) which usually indicate their purpose or limitations. In Windows, the shortcut is the most visible link for users but it is not a file system link. Instead it is a shell (user interface) link - that works the same on different file systems, i.e. FAT or NTFS. The name "shortcut" indicates that this it is intended to speed user access to the file but it is actually a shortcut to the file name. FYI, there can be links that work not just across disks but across different file systems and over networks.

A file system - examples are FAT/FAT32, NTFS, EXT2/EXT3 - stores the physical location of data so it can be accessed. The usual structure is that files have a file name which holds the information needed to locate and access the physical data in the file. These file names are organized in a logical structure so the file names can be found easily. Most file systems, including those already mentioned, use a hierarchy but some file systems have allowed arbitrary arrangements.

The word "file" is used as the electronic equivalent of physical files in an office - it won out over other terms but it was only introduced in the early 1960s. This is one of those situations where the usual understanding of file names gets in the way of understanding links because most users assume that the file names that they see, which also include links, are all the same as the primary file name used in the file system.

That's the situation when you say: "So, yes, saying that the file is truly "in" one dir or another in the presence of multiple hard links might be a misnomer." The answer is that the file name rather than the file is in the directory or folder.

The physical organization of data on the disk is generally not tightly coupled to the organization of file names and links. Although many disk defragmenters would arrange files based on the file name directories and folders, it was not a requirement of the FAT or NTFS file systems. Taking the DOS FAT file system as an example, the actual FAT (file allocation table for files) and the Root Directory were separate structures on the disk with the data area following. The root directory was small (512 file names from memory) and all sub-directories below the root directory were stored as special files in the sub-directory that hold them.

Remah, i think i get what you're saying and i think i agree.

When i say "in a folder" i really only mean as far as what windows file explorer reports as the disk space used for that folder. I get that windows file explorer abstracts away the notion that files are not actually "in" folders, and presents a simplified picture to the user that they are.

I still think the basic problem of having a file with 2 or more hard links from 2 or more folders will be reported by windows file explorer as taking up space "in" both folders, even tho there is only 1 file on disk taking up space once, remains.

Hmm, i wonder. If you had a 1 TB drive, and you created a folder FTOP and two folders underneath it, FA, and FB, and you created a 1TB file in FA, and then a *hard link* to the same file in FB, i wonder what it would report? Has anyone done this?

I bet file -> properties on the disk would read 1TB used (not 2TB) cuz it is looking at actual files on disk, not files listed in folders.

I bet file -> properties on FA and FB would report size used as 1TB each, implying that there are 2TB used on this disk, when really they're just reporting the *same* 1TB each.

File -> properties on FTOP? Would it say 2TB used? I wonder.

EDIT: Well i was curious, and i just tried it. Not with a 1TB file but with a 81KB file and FTOP did report 162KB used, and even 162KB "used on disk" (cuz that's just a block size rounding thing). I used mklink /h to make the hardlink. Not sure if that matters.

That was fun.

Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore Give error 87 Dism.exe /Online /Cleanup-Image give error 87 Cleanup-Image is unknown when I go Dism.exe /Online /? I do not see the option. This machine I am using is Windows 7 Professional service pack 1 32 bit

Hi bernardz,

As indicated above, I think Vic says to use the "previous tip" for Win7 and this new one for Win 8.1 -- I pasted the Win 7 one below. MS would not be MS if they did not change things on every OS version to keep us on our toes. I had to install a "suggested update" to get the Win 7 disk cleanup version to work but recovered several GBs of space. Check the Win 7 comments to see what else was required; I recall some issues.

http://www.techsupportalert.com/content/how-free-more-space-your-hard-dr...

It seems like Win 8.1 & various applications generate extraordinary numbers and MBs of .LOG files.

You can delete many of these to recover substantial disk space. The first time I searched on *.log on a relatively new laptop with regular CC use, I was amazed.

Try it for yourself but as cautioned above, beware of system files.

Correction: "Right-click the Windows flag in the lower-LEFT corner of your screen"

Whoops! I am becoming dyslexic in my old age. Thanks, Joe.

Me, too.
I am 67 yrs young.

Is there any means to automate this process of cleaning?

It happens to me too.