The dreaded system warning pops up: “Your disk is almost full”.
You’re in the middle of something and ignore that.Maybe you delete some files in downloads and desktop. Then move on (you know that’s not going to help).
A few days later… after the umpteenth warning, you start having to force quit applications. Then you look at Storage Tab. What’s in Documents? What’s in Other?
At this point, you start to realise you’re going to need to do something significant to remove the bloat on your system despite having “everything on the cloud”. So much for CI/CD!
🔮 The first thing is to reach for is the automated tools.
Docker
Docker can really hog the disk with a bunch of unused images, containers and volumes as we continuously try and test the latest images. While they do have very useful commands to purge everything unused with docker system prune
that can also remove containers that you might still be using. So I would recommend going by the order of:
- Removing your unused containers (and their volumes with
-v
)docker container rm -v
- Removing the dangling images
docker image prune
- Removing any volumes not previously removed
docker volume prune
Android
The largest source of bloat that you can clear would be duplicity. Having multiple AVDs, multiple SDKs, multiple Gradle versions downloaded for different projects. If possible, decide on a common support level or drop AVDs when not in use.
- AVD Manager — Remove ununsed AVDs in
- SDK Manager — Remove unused AVD Images *Show Package Details
- SDK Manager — Remove unused SDKs
- Gradle — Remove unused
~/.gradle
and.gradle
versions.
XCode
There’s a real nifty tool to clean up XCode with DevCleaner for XCode. The main idea is to remove the old archives and unused simulators. Before that, you might need to decide on the version you would like to keep.
- Delete your old versions of XCode
- Run DevCleaner for XCode
- Use xcrun cli to delete unavailable simulators
xcrun simctl delete unavailable
- Use xcrun cli to delete simulators you don’t develop for example watchOS
xcrun simctl list devices | grep -E -i "watch" | grep -E -o "([A-Z0-9]+-){4}([A-Z0-9]+)" | xargs xcrun simctl delete
NVM / Node
Clear out old versions of Node. I highly recommend using Node Version Manager if you haven’t.
- Find your old versions of node
nvm ls
- Delete the unused versions
nvm rm v10.16.3
Yarn / NPM
Package managers can hold a huge cache in efforts to speed up installations. Sometimes, they have really out of date caches, so clearing out the old packages becomes overdue. Be warned that the next time install is triggered, you might be in for a performance hit.
yarn cache clean
npm cache clean --force
Disk Utilities
A disk utility can identify hotspots that you might have overlooked, or verify that any of the above commands worked as expected. I’ve previously used Disk Inventory X but found DaisyDisk to be fast and up to task.
—
All the best 😄