[This post is above all for my own reference, so I’ll know what to do the next time this problem occurs.]

My Thinkpad’s SSD has an impolite tendency to run out of disk space, even though I might not really be adding lots of data. It seems to be mostly cruft that Debian accumulates, perhaps out of a desire for thorough record-keeping.

Looking for ways to free up disk space, I found this StackExchange post. It has bunch of ways for giving my hard drive a good scrub.

Let’s see what they do!

Helpful commands#

Start by emptying your Trash bin.

Clean up logs - this freed about 3GB of disk space.

sudo journalctl --vacuum-size=300M # reduces the logs to 300 MB

This freed about 3GB of disk space.

More log cleaning. Did not have any visible impact:

sudo logrotate /etc/logrotate.conf # compresses or (?) deletes system logs

Delete cached packages. I did this before starting a more systematic analysis, so I can’t say how much space it freed up. But it was easily more than one GB:

sudo apt clean # deletes packages that were cached for installation

Remove unused packages. Freed up a cool 1.9 GB:

sudo apt autoremove # removes unused packages

That’s all the straightforward commands that the linked post provided.

Finding large files#

In addition, it told me how to find large (<100MB) files, so that I can check whether I want to delete them:

sudo find / -mount -type f -size +100M -exec du -h {} \; | sort -n

But most of the results looked like they were at least somewhat important, so I didn’t actually go and delete any of them.

Remember to floss regularly#

Maybe I should simply put all these commands into a little script, and run that as a cron job? Once a month or so?