Windows and WSL2 Cleanup

Windows Cleanup

Identify large files and folders

use WinDirStat

du -sh C:\Users\siddj\AppData\Local\Microsoft\vscode-cpptools\ipch

Cleanup

powercfg /h off
  • powercfg /h off turns of Hibernate mode and removes c:\hiberfil.sys
  • delete unused .mp4 and other video files in Screen Recordings folder
  • uninstall unused programs

reduce System Restore / Shadow Copies

Windows stores restore snapshots here.

You can’t see it directly, but it may consume lots of space.

Check usage:

Open Admin PowerShell:

vssadmin list shadowstorage

Example output:

Used Shadow Copy Storage space: 18 GB
Allocated Shadow Copy Storage space: 20 GB

Reduce it

Open System Protection:

System Properties
 → System Protection
 → Configure

Set disk usage to something like:

3–5 GB

Or delete restore points.

delete Windows Component Store (WinSxS). This contains old Windows update files. Location: C:\Windows\WinSxS:

check size:

dism /online /cleanup-image /analyzecomponentstore

cleanup:

dism /online /cleanup-image /startcomponentcleanup

delete Windows Update Cache. Location: C:\Windows\SoftwareDistribution\Download

net stop wuauserv
del /s /q C:\Windows\SoftwareDistribution\Download\*
net start wuauserv

Other directories to clean:

rm -rf ~/.cursor

WSL2 Cleanup

Identify large files and folders

sudo du -xhd1 / 2>/dev/null | sort -h
du -hd1 ~ | sort -h
du -h ~/.cache/pypoetry/virtualenvs -d 1 | sort -hr | head -n 30

Common culprits: ~/.cache, ~/.vsode-server, ~/.npm, ~/.local, ~/.gradle

Cleanup

rm -rf ~/.vscode-server/data/CachedExtensionVSIXs
rm -rf ~/.vscode-server/data/User/workspaceStorage
rm -rf ~/.cache/vscode-cpptools/ipch
npm cache verify
pip cache purge

also remove unused poetry virtual environments

Compact WSL2

Powershell:

wsl --shutdown
Optimize-VHD -Path "C:\Users\siddj\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalState\ext4.vhdx" -Mode Full

Set maximum size of WSL2

edit ~/.wslconfig under Windows and set:

defaultVhdSize=230GB

References

This entry was posted in Computers, programming, Software and tagged , . Bookmark the permalink.

Leave a Reply