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.
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:
Format and partition the disk as required.
Apply the OS image to an NTFS partition using DISM:
DISM.EXE /Apply-Image /ImageFile:INSTALL.WIM /Index:1 /ApplyDir:C:\ /Compact:ON
Run BCDBOOT C:\WINDOWS to set up the OS to boot.
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
Comments
- Anonymous
September 16, 2015
I just tried it! Saved me 1GB of space in less than 6 minutes. Works for me. - Anonymous
September 16, 2015
Is there a sample scriptcustom step for configMgr that lets you change the Apply Operating System options. It would help us with something else we need to achieve. - Anonymous
September 16, 2015
Well, there was - I wrote one last year for WIMBoot. But I lost it somewhere along the way and didn't have time to recreate it. It is a little tricky. What sort of options are you looking to change? - Anonymous
September 17, 2015
The comment has been removed - Anonymous
September 18, 2015
compactos provides only very marginal space savings. Take a look at the infographic here:
www.zipmagic.co/screenshots.html#Guaranteed
If you are looking to compress your disk, this tool literally halves Windows 10's footprint - guaranteed! - Anonymous
September 29, 2015
"Microsoft-Windows-SetupImageInstallOSImageCompact" does not effect. - Anonymous
October 22, 2015
So how would this all come into play with creating a reference image to capture into a wim? If I have MDT applying the bits like the drivers, os files, software etc, where would I do this?
Or do I take a pc, do the dism commands listed above, capture that wim, and replace the W10 OS bits I have in MDT with that?
Thanks - Anonymous
October 22, 2015
This isn't something done at the time of image creation - it's done when the image is deployed, per machine. (The image capture process is file-based, so it won't even notice that the system has been "compacted.") - Anonymous
November 17, 2015
Honestly, what kind of user is seriously worried about 1GB in disk space? Or even 4GB?
Especially when there are things like System Protections that can take up as much as 50% of the disk?
I haven't built a computer with smaller than 115gb C: partition for 15 years. And I haven't built one that needed much more than that either. My current win10 laptop has a dual SSD in RAID0, so I have a bit more room for games and such, but for work, the computers in our network all range from 25 (fresh and clean) to 45~50gb of footprint on C. Anything up to that is perfectly fine. Anything less than that is just too fresh to count and anything more than that needs a bit of cleanup.
Rather than waste time with stuff like saving a couple of gigs, why not just set up some basic best practices for common hardware deployments.
And Gabe, WHERE IS OUR SECOND TASKBAR?
We want a second taskbar to make the most of single monitor setups.
OH and Aero Glass yeah? - Anonymous
November 17, 2015
You care if you have a 16GB or 32GB system. Otherwise, no, you don't.
As for the other complaints, please use the Windows Feedback tool to submit your feedback. It's safe to say Gabe doesn't read my blog. - Anonymous
November 17, 2015
Cleaning temporary directories & updates backups will probably free much more space and don't have that bad side effect of using more CPU for decompress ;) - Anonymous
November 18, 2015
"You care if you have a 16GB or 32GB system."
What person in their right mind would have that small of a hard drive these days? I can perhaps understand tablets having that little space, but all laptops and desktops should have at least 120 gigs or more of space. - Anonymous
November 18, 2015
Verygood - Anonymous
November 18, 2015
"What person in their right mind would have that small of a hard drive these days? I can perhaps understand tablets having that little space, but all laptops and desktops should have at least 120 gigs or more of space."
Industrial devices. - Anonymous
November 18, 2015
"all laptops and desktops should have at least 120 gigs or more of space" uh, yeah, unless you're an underfunded academic research lab running 32gb VMs. Welcome to the world of the real, Neo. - Anonymous
November 18, 2015
The comment has been removed - Anonymous
November 18, 2015
How do you set a condition that will enable compact on for hard drives 32GB and smaller? I have some computers, destined for use as digital signs, and they have 32GB SSDs (28GB usable), and the stock image of Win10 Enterprise with Powerpoint 2016 is around 26GB. - Anonymous
November 18, 2015
thank you for this product - Anonymous
November 18, 2015
I have to agree with codevark Robin, why SHOULD you have that much space when memory sticks are so cheap and now are larger than 1TB! - Anonymous
November 19, 2015
What about those running Personal Virtual Desktops.. Any saving is huge when deploying say 40 desktops in a VDI enviroment. - Anonymous
November 19, 2015
The comment has been removed - Anonymous
January 27, 2016
"What person in their right mind would have that small of a hard drive these days? I can perhaps understand tablets having that little space, but all laptops and desktops should have at least 120 gigs or more of space."
LOTS of student laptops are 16and 32GB SSD. When the overwhelming majority of work product is kept in the cloud, that seems sufficient...until updates and patches continue to nibble away those precious gigabytes. - Anonymous
August 02, 2016
First of all - thank you for this tool. And thank you for the new ways in which Windows 10 needs less and less of disk space. Very much welcome :) No wonder a lot of people say it's the best Windows ever!However I would like to raise little concern about SSD and wear - does compression, the process of compressing and uncompressing data cause wear to an SSD? Wear that without compression, uncompression, the data would be directly accessible, therefor reducing the amount of reads and writes?