Freeing Up Disk Space in C Drive
When Windows is running low on disk space on system drive, it starts to complain:
And some functionality stops working, e.g. Winodws Update fails with error 80070070 (Not Enough Space):
Here are some tools and tips for freeing up disk space on system drive.
Tools
Use Disk Cleanup Wizard
Use Disk Cleanup Wizard is one of the easiest ways to get disk space back, as it's pre-installed on Windows.
Press Win + R to call out the Run dialog, and run cleanmgr
to begin.
WinDirStat
Gain Insights on Disk Usage withWinDirStat is a disk usage statistics viewer and cleanup tool for various versions of Microsoft Windows.
We can gain great insights on how disk space is used with the directory list, the treemap, and the extension list presented in the user interface.
Everything
List Every Single File withEverything is a local file search engine, which aims to locate files and folders by name instantly.
With this tool, we can list all files on the computer or on a given drive, and sort them by size in a moment, so that we know how our disks are occupied by these large files.
Tips
Change or Remove a Program
Remove some unused programs to get disk space back.
Control Panel (View by Icons) --> Programs and Features
or Control Panel (View by Category) --> Uninstall a program
Move Paging File to Another Disk
Paging file is used when virtual memory is turned on (which is on and placed in C drive by default.)
While paging file is critical to system when physical memory runs out, we can move it to another drive so that space in system drive frees up.
This can usually free up 2-4 GB disk space depending on system physical memory size and configuration.
Control Panel -> System \
or Right-click Computer -> Properties -----|
or Win + Pause/Break / |
|
|------------------------------------------|
|
|-> Advanced system settings (in left sidebar) -> Performance -> Settings... --|
|
|------------------------------------------------------------------------------|
|
|-> Advanced -> Virtual memory -> Change... --|
|
|------------------------------------------- |
|
|-> 1. Uncheck "Automatically manage paging file size for all drives;
2. Set paging file on C: drive to "No Paging file";
3. Set paging file on another drive to "System managed size".
Disable/Configure hibernation
Hibernation feature of Windows uses a hiberfil.sys
hidden system file located in the root folder of system drive (C:) which generally occupies disk space the amount of physical memory size.
So if you are not using hibernation feature, disabling it will free up several gigabytes of disk space.
To make hibernation unavailable, follow these steps:
- Click Start, and then type
cmd
in the Start Search box.- In the search results list, right-click Command Prompt, and then click Run as Administrator.
- When you are prompted by User Account Control, click Continue.
- At the command prompt, type
powercfg.exe /hibernate off
, and then press Enter.- Type
exit
, and then press Enter to close the Command Prompt window.
β How to disable and re-enable hibernation on a computer that is running Windows
Or if you do use hibernation feature, you may choose to reduce the size of hiberfil.sys
with the following command powercfg.exe /hibernate /size 50
, though this increased the chance that hibernation fails because the contents of memory cannot be compressed enough to fit within the size of the hibernation file. (Reference: What happen if we reduce the size of hiberfil.sys - Super User)
However, in any case, you won't be able to change the location of hibefil.sys
because of technical restrictions. See Windows Confidential: The File System Paradox.
Move Program Directories to Another Drive and Link Back
Another way to get disk space on C drive back without removing installed programs is to move the files and folders of them to another drive and link back to the original drive.
Say we have a program installed at C:\Program Files\RealVNC
. We can move this program to another drive without affecting its functionality with the following steps:
- Exit the program;
- Move it to another drive, say
D:\Program Files\RealVNC
; - Open
cmd.exe
; - Run
mklink /j C:\Program Files\RealVNC D:\Program Files\RealVNC
to link back the program to its original location. - Done. Start your program to test it.
Some programs may have background service running or have some DLLs registered. If there are errors when moving a program directory, Unlocker can be used to kill related processes and release file locks.
C:\ProgramData\Package Cache\
to Another Drive and Link Back
Move Package caching is a technology used in many Windows Installers which copies installed packages to a fixed location depending on whether a package is installing for all users (per-machine) or just the current user (per-user).
The per-machine location used in package caching is %ProgramData%\Package Cache\
(usually C:\ProgramData\Package Cache\
). This directory grows greatly as time goes by. So we may move it to another drive and link it back as mentioned in the previous tip.
C:\Windows\Logs\CBS\
Delete Files in CBS (Component Based Servicing, aka. trusted installer TRUSTEDINSTALLER.EXE
) allows components and features from IIS to Windows Media Player to be packaged as small modules that encompass the full functionality of the component. It writes logs to C:\Windows\Logs\CBS\
.
Generally, these logs won't be too large. But in certain cases, the log file can go as large as several GiB. And when the file goes beyond 2 GiB in size, you disk space will be eaten up finally.
This problem happens because the .CAB format has a 2GiB file size hard limitation, and TrustedInstaller will continue to issue
makecab
routinely, creating a new ~100MiB file in your temp folder each time. The solution is to remove the 2GB log file (which can safely be done, as these are only used for troubleshooting).
β Why is CBS.log file size 20 GB - Super User
So if your disk space gets crammed quickly even if you have just cleaned up your disk, be sure to check the size of C:\Windows\Logs\CBS\
.