Free up Windows 10 Disk Space with Compact OS
Compact OS is a new command line tool that Microsoft introduced in the Windows 10 operating system in an effort to reduce the system's disk footprint.
Probably the biggest change to previous versions of Windows in this regard is that Windows 10 does not need recovery images anymore, as the operating system will use existing files for that instead.
Compact OS is a new compression mechanism which takes files of the operating system and puts them in a (hidden) compressed container.
There is a lot that you can do with Compact OS, especially when it comes to optimizing and deploying images.
What's probably most interesting from an end-user's perspective is that you may change from a non-compacted to a compacted OS on a running system.
Free up Windows 10 Disk Space with Compact OS
If you do that, you may free up several Gigabytes of storage on the hard drive because of it. Mileage may vary but I have yet to come upon a system where the Compact OS operation would not free up at least 2 Gigabytes of space.
2 Gigabytes may not be much depending on available hard drive space. Running the operation makes sense if Windows is installed on a partition with little hard drive space, or a Solid State Drive that is low on space.
All commands are run from an elevated command prompt.
- Tap on the Windows-key.
- Type cmd.exe
- Hold down Shift and CTRL.
- Select the Command Prompt result to open an elevated command prompt.
Determine the state of OS binaries
Before you do any compacting, you may want to determine the current state of OS binaries to find out whether the OS is already compressed.
Run the following command to determine that:
- compact.exe /q
The command line tool returns information about the state. This includes how many files are compressed or not compressed, the compression ratio, and how many bytes of data are stored in the compressed container.
If the compression ratio is 1,0 to 1 or close to that, then the OS is not compressed.
Compressing the OS binaries to save up disk space in Windows 10
Compression may impact performance under certain circumstances but it should not be noticeable on most systems.
Please note that you can go back to an uncompressed state at any point in time if you notice issues after compressing the OS. Also, to be on the safe side, it is recommended to back up important data before you continue.
Run the following command to compress OS binaries:
- compact.exe /CompactOS:always
The operation may take several minutes to complete (on some systems 20 or more minutes). The amount of space you save depends on a number of factors. A test on the latest Insider Build installation of Windows 10 saved more than 2 Gigabyte of disk space after the compression.
To revert the change later on, run the following command to uncompress the data:
- compact.exe /CompactOS:never
The operation does not take as long as the compression usually. Windows will occupy more disk space afterwards though so keep that in mind.
Now Read: Run Disk Cleanup to free up lots of space on Windows 10
This completely kills performance of the OS though.
I did not notice any issues on my machine. What are the stats of the machine that you noticed the performance drop?
Why it is faster:
When reading a binary file from the disk to the memory it takes a time.
The larger the binary file the longer it takes.
Long story short: it is faster to read compressed data from the disk to the memory then uncompress it than read the plain (whole/uncompressed) data from the disk to the memory.
When you taking a trip which is faster: pack in one bag all your stuff even if you get a very tight bag OR pack 3 bags with the same stuff?
However, I didn’t notice any disk space gain from running “compact.exe /CompactOS:always”
I don’t keep my personal files on Drive C. This keeps Windows running as fast as possible. I have them on Drive D and back them up on a removable flash drive.
Personal files don’t cause performance issues unless you’re searching through them or have a lot of files and trying to view them.
Performance issues generally arise if your space is low, files are fragmented (ignore if you use SSD) or programs running in the background. There are other ways to make your Windows slower, such as cluttered registry.
Slight issue if your desktop is being used as a “My documents” folder and bunch of icons are all over the place tho :-P
Putting your personal files on another hard drive is always a great thing tho. Less chance of losing them if an update bricks your installation (which is bound to happen with Windows’ track record).
Is this the same thing as ticking ‘Compress this drive to save space’ option in My Computer?
No this is different. This method won’t affect non-OS files at all.
Thanks Martin for another interesting article – I appreciate your daily postings. I check them out most days. Some are just a little too technical for my understanding but I have learned a lot from the ones that didn’t make over my head! Keep up the good work, I’m sure many people also appreciate it!
Windows 10 Compact OS seems interesting… Reading this gave me a feeling of dÃ©jÃ vuâ€¦ itâ€™s just like Superstor (the on-the-fly disk compression) in DR-DOS 6.0 back in about 1991 or 1992â€¦ but then probably not many of you had been born back then :-).
Yes thank you Martin for showing me new stuff, I would say if you need to do this to free up 2 gigs of room, just buy a 250 gb 7200 rpm hdd on ebay for like 11 bucks. Or go to the local big lots or wal mart and buy an 16 gb stick for 10 bucks.
Don’t buy HDD’s for system drives anymore pls :D
This might be very helpful on tablets or if you have a small-ish SSD for system drive. Good stuff.
On my PC it says the compression ratio is 1,4/1, so I guess it was already…
I keep getting access violation issues even when I run as Admin I can run compact /q and get results bur compact .CompactOS:always throws up the access violation issue.
compaq /q gave ma 1,4 as well, when i did always i got no change,
When i disabled it with never and then always again i got 1,6.
Weird enough so perhaps give that a try :).
Sure but since it is a bit risky, I am not sure I would change from such a limited gain. Thanks anyway for the tip. BTW, did you try to reboot after re-compacting ? I once had a bad surprise on a XP system with Windows NTFS compression…
This seems to be enabled by default for System32 (though, oddly, not “new files” added to that directory) for some reason. The screenshot shows that as well as my Insider system. I certainly didn’t enable it before since I never knew of it.
This can hurt performance if you have a SSD, a fast HDD, or a very slow CPU. Your typical cheapo laptop with a 32GB eMMC SSD and a Celeron CPU will often come with Windows 10 in CompactOS mode, yet the Celeron processor means the decompression is slow and the read speed of an eMMC SSD is faster than a Celeron CPU can decompress. It’s done for space savings due to the tiny size of the SSD but it’s probably not worth it on such machines. If you have a faster CPU and a slower hard drive, you may have the opposite result.