Home Knowledge Base Compact OS — Compress the OS to Free Up Disk Space
Windows CMD Tool

Compact OS — Compress the OS to Free Up Disk Space

Compact OS runs Windows directly from compressed files, saving between 2.75 GB and 4.75 GB without deleting files or impacting performance on SSDs. Can be enabled or disabled at any time from CMD.

SystemWindows 10 / 11
Typical savings2.75 GB – 4.75 GB
PrivilegesAdministrator
Case 1 — Check current status
From running Windows (CMD as Administrator)
Compact.exe /CompactOS:Query
From WinPE — replace E:\Windows with the correct path
Compact.exe /CompactOS:Query /WinDir:E:\Windows
Case 2 — Enable / Disable Compact OS
Enable — Windows runs from compressed files (recommended on SSDs)
Compact.exe /CompactOS:always
Disable — reverts to uncompressed state
Compact.exe /CompactOS:never
Case 3 — Apply compressed image with DISM (WinPE / deployment)
Applies install.wim directly in compact mode when installing Windows
DISM /Apply-Image /ImageFile:install.wim /Index:1 /ApplyDir:D:\ /compact
Case 4 — Clean and export offline image with DISM
Mount image
Dism /Mount-Image /ImageFile:"C:\Images\install.wim" /Index:1 /MountDir:C:\mount\Windows
Clean up superseded components (may take several minutes)
Dism /Cleanup-Image /Image=C:\mount\Windows /StartComponentCleanup /ResetBase
Unmount and commit changes
Dism /Unmount-Image /MountDir:C:\mount\Windows /Commit
Export to new optimized file
Dism /Export-Image /SourceImageFile:C:\Images\install.wim /SourceIndex:1 /DestinationImageFile:C:\Images\install_cleaned.wim
Case 5 — Shrink hiberfil.sys (additional savings)
Reduce by 30% — keeps hibernation active
powercfg /h /type reduced
Remove completely — disables hibernation and saves ~1.5 GB on 4 GB RAM systems
powercfg /h off
Compact OS optimal on SSD · Not recommended on rotational HDD
Microsoft Docs