Thursday, March 1, 2018

Free up disk space on 2008/R2 Servers

It's no secret that 2008/R2 servers do a horrible job with the WinSxS folder growing ridiculously out of control. Microsoft's stance is, "Deal with it." They have options for newer operating systems, but 2008/R2 is not so blessed. If you have a physical server, or other reasons the disk is unable to be easily expanded, you can be desperately low on free disk space, while WinSxS consumes over 20GB. Here's what I've found that helps, with no reboots required:

First, try to clean up the files left over from a Service Pack installation with the following command:
DISM.exe /online /Cleanup-Image /SPSuperseded

That can sometimes buy you a few GB, but if you need more, consider compressing the WinSxS folder, which can free up many GBs, as you can see in this example. Since compression doesn't delete anything, and these files are seldom referenced, it should result in no negative impact upon the server.



Step 1 - Stop services and backup ACL
sc stop msiserver
sc stop TrustedInstaller
sc config msiserver start= disabled
sc config TrustedInstaller start= disabled
icacls "%WINDIR%\WinSxS" /save "%WINDIR%\WinSxS.acl" /t

Step 2 - Take ownership
takeown /f "%WINDIR%\WinSxS" /r

Step 3 - Grant permissions
icacls "%WINDIR%\WinSxS" /grant "Domain\Username":(F) /t
*This would be the username you have used to login to the server, or you can always grant it to a group of which your account is a member, like Domain Admins.

Step 4 - Compress files
compact /s:"%WINDIR%\WinSxS" /c /a /i *

Step 5 - Restore permissions
icacls "%WINDIR%\WinSxS" /setowner "NT SERVICE\TrustedInstaller" /t
icacls "%WINDIR%" /restore "%WINDIR%\WinSxS.acl"

Step 6 - Delete ACL backup and start services
del "%WINDIR%\WinSxS.acl"
sc config msiserver start= demand
sc config TrustedInstaller start= demand

No comments:

Post a Comment