Archive for January 12th, 2015

Tip (Updated): Running out of storage? Slim down Windows 8.x and Windows Server 2012 R2 HDD use Part 1

Monday, January 12th, 2015

Hi Folks,

you run several Windows 2012R2 Servers or Windows 8.x VDI’s? You have Windows devices with small HDD’s/SSD’s? You run out of storage or you want to reduce the Windows Footprint in general?

Here are some supported and unsupported steps you can do… “Can be used with WIM boot installation” points to the new Install Option for OEM Vendors, mostly used for Windows 8.1 with Bing and low SSD devices. For a WIM boot description get a look here: WIM boot explained

1) Disable Hibernation

Hibernation could be usefull but I see mostly that Users are using the sleep/standby mode. The difference between the sleep/standby Mode is quite simple to explain. In standby mode the computer hold the current RAM state in the RAM and consume still some power, in hibernate Mode the RAM content will be placed on the HDD/SDD and the computer really shutdown. The disadvantage in this case is quite simple, it always consumes 75% of the total ram size with a file called “hiberfil.sys” on drive C:. So if you don’t need the hibernate mode, disable it…

Command (command line):

powercfg -h off

Supported by Microsoft: Yes
Require Administrator Permission: Yes
Produced space on HDD: 75% of the total RAM Size
Can be used with WIM boot installation: Yes
Disadvantage: Hibernation mode is not available

2) Remove superseded Updates/Windows files

Windows by design increase the used amount of HDD Space.. By default all installed Windows updates and also the old original files will be hold to roll back the updates. So if you have an old Windows System and you run Windows Update all the time, all this files will be hold and consume a lot of HDD space. You can remove this old stuff quite simple, this should be done everytime you create a golden image or after you run Windows Update…

Update: I’ve been asked if this is similar to the Windows Update clean up provided by the Windows disk clean up tool. No it’s not similar and will provide more free space as extension to the disk clean up tool

Command (command line):

dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase

Supported by Microsoft: Yes
Require Administrator Permission: Yes
Produced space on HDD: 0->4GB depending on how much Windows Updates applied
Can be used with WIM boot installation: Yes but smaller effect.
Disadvantage: Windows Updates can’t be rolled back in case of issues, test the Windows before you roll-out it.

3) Compress the “winsxs” and some other Windows folders (UNSUPPORTED!)

Windows comes with a sub directory called “winsxs”, this is one of the most important Windows folders because this folder holds all Windows Installation Files and a lot of active used Windows Files are pointed to the files in the “winsxs” folder. This folder requires a lot of space and it could make sense to compress it if possible. By design this task is not simple to do and we need a more complex script to do it. You can also compress some other folders like the Fonts directory without any issue in the same step.

I use this script since a long time (> 12 Months) now and with a couple of test / low storage system’s like my Surface Pro, until now i never got an issue but i don’t recommend to use this in any Windows Server production environment.

Commands (command line, save as wincompress.bat):

echo Compress Windows folders
compact /s:"%WINDIR%\Fonts" /c /a /i *
compact /s:"%WINDIR%\Temp" /c /a /i *
compact /s:"%WINDIR%\Web" /c /a /i *
compact /s:"%WINDIR%\assembly" /c /a /i *
compact /s:"%WINDIR%\debug" /c /a /i *
compact /s:"%WINDIR%\LastGood" /c /a /i *
compact /s:"%WINDIR%\ShellNew" /c /a /i *
echo Compress winsxs folder
icacls "%WINDIR%\WinSxS" /save "%WINDIR%\WinSxS.acl" /t
takeown /f "%WINDIR%\WinSxS" /r
icacls "%WINDIR%\WinSxS" /grant "%USERDOMAIN%\%USERNAME%":(F) /t
compact /s:"%WINDIR%\WinSxS" /c /a /i *
icacls "%WINDIR%\WinSxS" /setowner "NT SERVICE\TrustedInstaller" /t
icacls "%WINDIR%" /restore "%WINDIR%\WinSxS.acl"

Supported by Microsoft: No, support is lost! (You use the script on your own risk!)
Require Administrator Permission: Yes
Produced space on HDD: ~3GB-5GB
Can be used with WIM boot installation: No, never use it with a WIM installation! Why? The files in the winsxs folder in a WIM boot installation are mapped from the recovery partition. If you compress now the files the files will be shifted/written into the Windows partition and this will highly blow up the used space.
Disadvantage: System requires some CPU resources to handle the compressed files, system is now without any support from Microsoft. Do never abort the script once running, run it only with a 100% stable system! Script needs some time to run… If running on a physical hardware create a recovery partition on a USB Memory in advance: How to create a recovery partition on a USB memory or create a snapshot if used with a VM. Once the script is finished you will receive always a message that the script execution failed for one file, this is by design and no issue at all.
This is Part 1 of this article, Part 2 can be found here: Slim down Windows 8.x and Windows Server 2012 R2 HDD use Part 2

 

Cheers

Michael

P.S.: Figures shown as produced savings are max. savings, on a fresh installed windows the savings will be lower.