2.9 KiB
name, description
| name | description |
|---|---|
| macos-disk-cleanup | Use when a Mac disk is full. Find hogs, clean, verify freed. |
macOS Disk Cleanup
Procedure
-
Diagnose the real picture first.
df -h /for headline capacity, but alsodiskutil apfs list | grep -E "Capacity|Size"— on an APFS container with multiple volumes (system, data, VM, Preboot) the root/numbers can mislead;/System/Volumes/Datausually holds the user data and is the one that's actually full.- Rank hogs top-down, not file-by-file:
du -sh ~/* | sort -rh, then drill into the biggest hits (~/Library/*,/Applications/*.app,/Library/Developer/*). Don'tduthe whole tree at once — rank one level, descend only into the big entries. - Treat any
/private/var/folders/.../Nextcloud.app/Wrapperor similar sandbox mount showing huge usage as a view of the SAME underlying volume, not a separate cost — don't double-count it.
-
After deleting anything, the freed space often does NOT show up in
dfimmediately. Check for local Time Machine snapshots holding the deleted blocks:tmutil listlocalsnapshots /tmutil deletelocalsnapshots <snapshot-date-id>for eachcom.apple.TimeMachine.*entry (leavecom.apple.os.update-*ones alone, those are OS-update snapshots).- Re-run
df -h /after — this step alone can be the difference between "nothing was freed" and the real number. Always check this before telling the user a deletion didn't help.
-
Xcode iOS Simulator bloat (
/Library/Developer/CoreSimulator, often tens to 100+ GB) is safe to clear without touching Xcode.app itself:xcrun simctl delete all(removes simulator device instances)xcrun simctl runtime delete all(removes the downloaded iOS runtime disk images — this is where most of the space actually is, inCoreSimulator/Volumesand/Cryptex)- Verify with
du -sh /Library/Developer/CoreSimulatorbefore/after.
-
Files refusing to delete with "Operation not permitted" despite correct ownership are usually flagged immutable (
uchg), common in old synced/backup folders:- Check:
ls -lO <file>(flags column showsuchg). - Fix:
chflags -R nouchg,nouappnd,noschg,nosappnd <dir>then retryrm -rf.
- Check:
-
Deduplicating against a reference/cloud copy: match candidates by
(filename, exact byte size), not filename alone. Files with the same name but a different size are a different export/version — do not delete those without explicit confirmation, even if the user said "duplicates can go". Report the ambiguous set back instead of guessing. -
Before pronouncing something "long unused" for cleanup (e.g. local LLM models, caches), check
stat -f "%a %m" <file>for actual access/modify time — don't assume age from directory listing alone. If there's only one item in the category asked about, there's nothing to "sort out"; say so rather than inventing a selection.