Skip to content

Instantly share code, notes, and snippets.

@joseluisq
Last active August 6, 2021 09:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joseluisq/aefef14c99b92e51f9bbaeaaad5d01d8 to your computer and use it in GitHub Desktop.
Save joseluisq/aefef14c99b92e51f9bbaeaaad5d01d8 to your computer and use it in GitHub Desktop.
How to save space on disk removing ArchLinux Pacman packages cache

How to save space on disk removing ArchLinux Pacman packages cache

1. Check out how many space is taken by Pacman packages cache

ls /var/cache/pacman/pkg/ | wc -l
# 13886
du -sh /var/cache/pacman/pkg/
# 61G	/var/cache/pacman/pkg/

2. Deletes all cached versions of installed and uninstalled packages, except for the most recent 3

paccache -r
# ==> Privilege escalation required
# [sudo] password for joseluisq:
# ==> finished: 8795 packages removed (disk space saved: 46.62 GiB)
ls /var/cache/pacman/pkg/ | wc -l
# 5092

3. Discard unused packages weekly

sudo systemctl start paccache.timer
sudo systemctl enable paccache.timer
sudo systemctl status paccache.timer
# ● paccache.timer - Discard unused packages weekly
#     Loaded: loaded (/usr/lib/systemd/system/paccache.timer; enabled; vendor preset: disabled)
#     Active: active (waiting) since Thu 2020-09-24 09:50:44 CEST; 3s ago
#    Trigger: Mon 2020-09-28 00:00:00 CEST; 3 days left
#   Triggers: ● paccache.service
#
# set 24 09:50:44 localhost systemd[1]: Started Discard unused packages weekly.

4. Remove all cached versions but keeping the N ones (Optional)

paccache -rk 1

Replace 1 with the number of versions that you want to preserve.

More details on ArchLinux Pacman - Cleaning the package cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment