Cleaning up a linux machine (arch)

TLDR

journalctl --vacuum-size=100M #remove all logs, only retain 100mb
pacman -Scc #remove all package installation files (obsolete and current)
pacman -S bleachbit
bleachbit -c system.*

First, what's big on the system

du -d1 -h / 2>/dev/null | sort -h

This shows a sorted list of the largest dirs in `/`
You can do two levels down:

du -d2 -h / 2>/dev/null | sort -h

My result is:

0 /proc
0 /sys
0 /tmp
12K /dev
12K /srv
16K /lost+found
632K /run
4.3M /boot
13M /opt
15M /etc
75M /root
93M /home
2.4G /var
3.2G /usr
221G /mnt
227G /

I ignore /mnt (because that's an external drive)
Two dirs stand to mind: var and usr.
Let's see what's inside:

du -d1 -h /var /usr 2>/dev/null | sort -h

Then, a little bit deeper:

du -d1 -h /var/log /usr/share /usr/lib /var/cache 2>/dev/null | sort -h

Let's start with the logs

I have 717mb in /var/log.

I'm not a fan of deleting directories randomly, so let's do it the clean way:

$ journalctl --disk-usage
Archived and active journals take up 728.7M on disk.

Let's leave only 100mb of logs:

journalctl --vacuum-size=100M
...
Deleted archived journal /var/log/journal/ba5391...b.journal (8.0M).
...
Vacuuming done, freed 616.6M of archived journals on disk.

More info here on how to configure journalctl here.

Packages

I have 660M /var/cache/pacman. It was 1.8gb, but I ran pacman -Sc to remove unused packages. Let's remove the rest:

pacman -Scc

/usr/share/locale

A lot of users do remove it, or at least clean it up. But I might be a problem. But checkout bleachbit (next paragraph).

Bleachbit

Automatic cleaner. Will delete a lot of stuff, but for it was mostly locales.

$ pacman -S bleachbit
$ bleachbit -p system.*
Disk space to be recovered: 488.8MB
$ bleachbit -c system.*

You can look for more stuff to delete:

bleachbit --list
bleachbit -p thunderbird.*

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.