On this pageStep 1: find what is using the space
A full C: drive on a Windows server is more than an annoyance. Updates fail, services that cannot write logs crash, and databases stop accepting writes. There are two ways out: free the space you already have, or add space and grow the partition. On a virtual server the second is often the quicker fix, but cleaning first tells you whether something is leaking. This guide covers both, and the recovery partition that blocks most attempts to extend C:.
Step 1: find what is using the space
Start with the volume, then rank the top-level folders by size. Run PowerShell as administrator so protected folders are counted:
Get-Volume -DriveLetter C
Get-ChildItem C:\ -Directory -Force -ErrorAction SilentlyContinue | ForEach-Object {
$bytes = (Get-ChildItem $_.FullName -Recurse -File -Force -ErrorAction SilentlyContinue | Measure-Object Length -Sum).Sum
[pscustomobject]@{ Folder = $_.FullName; GB = [math]::Round($bytes / 1GB, 2) }
} | Sort-Object GB -Descending | Select-Object -First 10
The scan takes a while on a large disk. Repeat it on the biggest folder to drill down. These are the usual suspects on a server:
| Location | What it is | Safe action |
|---|---|---|
C:\Windows\WinSxS |
The component store | Clean with DISM only, never by hand |
C:\Windows\SoftwareDistribution\Download |
Windows Update download cache | Clear it with the update service stopped |
C:\inetpub\logs\LogFiles |
IIS logs | Delete or archive old files, then automate it |
C:\Windows\Temp and user temp folders |
Temporary files | Delete files older than a few days |
C:\Users |
Profiles, including old accounts and downloads | Remove stale profiles from System Properties |
C:\hiberfil.sys |
Hibernation file | Turn hibernation off; servers rarely need it |
System Volume Information |
Shadow copies | Cap their size with vssadmin |
C:\Windows\Installer |
Cached installers for updates and programs | Leave it alone; removing files breaks repairs and uninstalls |
Application data is the other big one: SQL Server databases and backups, mail stores, and log folders under C:\ProgramData. Moving those to a second volume is usually a better long-term answer than cleaning around them.
Step 2: clean up safely
The component store
WinSxS looks enormous partly because it contains hard links to files that also live in System32, so Explorer counts them twice. DISM reports the real size and whether a cleanup will help:
Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore
Dism.exe /Online /Cleanup-Image /StartComponentCleanup
StartComponentCleanup removes components replaced by newer updates. Windows runs the same task on a schedule, but running it after a big update reclaims the space now. Adding /ResetBase frees a little more but makes every installed update permanent: you can no longer uninstall them. Use it only on a server whose current patch level you trust.
The Windows Update cache
Downloaded updates that are already installed can be removed. Stop the services first so nothing is in use, and do not do this while an update is installing:
Stop-Service -Name wuauserv, bits -Force
Remove-Item -Path C:\Windows\SoftwareDistribution\Download\* -Recurse -Force
Start-Service -Name wuauserv, bits
Windows downloads again whatever it still needs.
Old logs and temp files
Preview with -WhatIf, then run without it:
Get-ChildItem C:\inetpub\logs\LogFiles -Recurse -File |
Where-Object LastWriteTime -lt (Get-Date).AddDays(-30) | Remove-Item -WhatIf
Get-ChildItem $env:TEMP, C:\Windows\Temp -Recurse -File -ErrorAction SilentlyContinue |
Where-Object LastWriteTime -lt (Get-Date).AddDays(-7) | Remove-Item -Force -ErrorAction SilentlyContinue
Put the log line in a scheduled task so the folder never grows back unchecked.
Disk Cleanup, hibernation and shadow copies
On Windows Server 2016 and later with Desktop Experience, Disk Cleanup is built in. Run cleanmgr /sageset:1 once to pick categories (including system files), then cleanmgr /sagerun:1 whenever you need it. Server Core does not include it, so use the commands above there.
Two quick wins remain. powercfg /h off deletes the hibernation file, which is the size of a large share of RAM. And shadow copies, used by restore points and some backup tools, can be capped:
vssadmin list shadowstorage
vssadmin resize shadowstorage /for=C: /on=C: /maxsize=10%
Remove profiles of people who no longer use the server from System Properties > Advanced > User Profiles > Settings, which deletes the folder and the registry entries together.
Step 3: add space and extend C:
Cleaning buys time; a disk that fills every month needs more space. On CloudSat you move to a bigger plan from the console (resize a server). When a disk grows, Windows does not touch the partitions: the new space appears as unallocated at the end of the disk. Rescan, check how far C: can grow, then extend it:
Update-HostStorageCache
Get-PartitionSupportedSize -DriveLetter C
Resize-Partition -DriveLetter C -Size (Get-PartitionSupportedSize -DriveLetter C).SizeMax
In the GUI, the same is Disk Management > Action > Rescan Disks, then right-click C: and choose Extend Volume. Before changing partitions on a server you care about, take a snapshot (take a snapshot).
When Extend Volume is greyed out
A volume can only grow into unallocated space directly after it. Many Windows images put a small recovery partition (Windows RE) right after C:, so the new space ends up behind it and SizeMax equals the current size. The simplest fix on a virtual server is to move Windows RE onto C:, delete the recovery partition and extend:
reagentc /info
reagentc /disable
diskpart
Inside diskpart, check the partition numbers carefully. The recovery partition is listed with the type Recovery:
list disk
select disk 0
list partition
select partition 4
delete partition override
select volume C
extend
exit
Then turn Windows RE back on and confirm where it lives now:
reagentc /enable
reagentc /info
With no recovery partition left, Windows keeps the recovery image in C:\Recovery\WindowsRE, and it still works. If you prefer a separate recovery partition, Microsoft's KB5028997 shows how to shrink C: and recreate one with the right partition type and attributes after you have extended.
Keep it from filling up again
Most full disks fill slowly, so a warning a few weeks early beats any cleanup. Two habits cover most servers. First, give every log folder a retention task like the one above. Second, check free space daily and leave a trace your monitoring can catch. This example writes a warning to the Application log when C: drops below 15% free; register the event source once with New-EventLog:
New-EventLog -LogName Application -Source DiskCheck
$c = Get-Volume -DriveLetter C
if (($c.SizeRemaining / $c.Size) -lt 0.15) { Write-EventLog -LogName Application -Source DiskCheck -EventId 9001 -EntryType Warning -Message 'C: is below 15% free' }
Run the last two lines from a daily scheduled task. The cmdlets ship with Windows PowerShell 5.1, the default shell on Windows Server.
FAQ
Can I delete files in WinSxS by hand?
No. Removing files from the component store breaks updates, feature installs and repairs, and the only fix may be a reinstall. Use StartComponentCleanup and, if needed, the repairs in DISM and SFC.
Is it safe to delete the SoftwareDistribution folder?
The Download subfolder is safe to empty with the update services stopped. Deleting the whole folder also works but wipes the local update history, which makes troubleshooting later updates harder.
Does NTFS compression help?
For text-heavy folders such as IIS or application logs, often a lot. compact /c /s:C:\inetpub\logs\LogFiles compresses the existing files and marks the folder so new files are compressed as they are written. Avoid it for databases, virtual disks and anything already compressed, where it costs CPU for little gain.
Why can I not shrink C: as far as the free space suggests?
Shrinking stops at the last file Windows cannot move, such as the page file, the hibernation file or shadow copies near the end of the volume. Turning those off temporarily, shrinking, then turning them back on usually gets you further.
Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.




