Pacman Cache management

I have just had pacman fail due to a full /var partition. On inspection I had over 90 GB in /var/pacman/cache going back to 2017, when I first ran manjaro. I deleted thousands of entries, leaving only those since 2024.

How is the cache managed? How do I prevent it filling up again?

Have a look here:

Section 1.5 here: pacman - ArchWiki

In terminal: man pacman

That is how to use pacman, not its cache.

Section 1.5 of the Arch Wiki details the commands to manage pacman cache.

By default pamac caches the last 3 versions of every package, if you don’t tell it to do otherwise.
This means, if you have a 30 gb real system, after an year or two you will have an addition of 90gb cache.

And if you use pacman or yay, they keep indefinite number of old stuff.

If you have libpamac installed on your system, then you should also have the pamac-cleancache.timer service active, and that should regularly clean the pacman cache:

❯ systemctl status pamac-cleancache.timer
● pamac-cleancache.timer - Monthly clean packages cache
     Loaded: loaded (/usr/lib/systemd/system/pamac-cleancache.timer; enabled; preset: disabled)
     Active: active (waiting) since Fri 2026-07-31 18:17:43 AEST; 2h 21min ago
 Invocation: bddbc030b1cc42d89dfbabfa2c62448d
    Trigger: Sat 2026-08-01 15:00:00 AEST; 18h left
   Triggers: ● pamac-cleancache.service

Jul 31 18:17:43 scott-ser systemd[1]: Started Monthly clean packages cache.

The timer launches the pamac-cleancache.service, which runs the pamac clean --no-confirm command:

❯ grep -i exec /usr/lib/systemd/system/pamac-cleancache.service
ExecStart=/usr/bin/pamac clean --no-confirm

The pamac clean command follows the KeepNumPackages = setting in /etc/pamac.conf. For example, mine is set to keep the last 3 versions of each package:

❯ grep -i keep /etc/pamac.conf
## Keep built packages from AUR in cache after installation:
#KeepBuiltPkgs
## Number of versions of each package to keep when cleaning the packages cache:
KeepNumPackages = 3

So, for automated cleaning of your packages cache you should ensure that the pamac-cleancache.timer is active. You can also run the service manually at any time with the following command:

systemctl start pamac-cleancache

You can check if it worked successfully by running systemctl status pamac-cleancache:

❯ systemctl status pamac-cleancache
○ pamac-cleancache.service - Clean packages cache
     Loaded: loaded (/usr/lib/systemd/system/pamac-cleancache.service; static)
     Active: inactive (dead) since Fri 2026-07-31 20:48:58 AEST; 15s ago
 Invocation: b7c49143020444abab50cfe1baa0f3ab
TriggeredBy: ● pamac-cleancache.timer
    Process: 299809 ExecStart=/usr/bin/pamac clean --no-confirm (code=exited, status=0/SUCCESS)
   Main PID: 299809 (code=exited, status=0/SUCCESS)
   Mem peak: 16.4M
        CPU: 114ms

Jul 31 20:48:58 scott-ser systemd[1]: Starting Clean packages cache...
Jul 31 20:48:58 scott-ser pamac[299809]: Number of versions of each package to keep in the cache: 3
Jul 31 20:48:58 scott-ser pamac[299809]: To delete: 0 files
Jul 31 20:48:58 scott-ser systemd[1]: pamac-cleancache.service: Deactivated successfully.
Jul 31 20:48:58 scott-ser systemd[1]: Finished Clean packages cache.

You can also use the paccache command, which is included in the pacman-contribpackage, to clean your pacman cache:

paccache --help
❯ paccache --help
paccache v1.13.1

Flexible pacman cache cleaning utility.

Usage: paccache <operation> [options] [target ...]

Operations:
  -d, --dryrun      perform a dry run, only finding candidate packages
  -m, --move <dir>  move candidate packages to "dir"
  -r, --remove      remove candidate packages

Options:
  -a, --arch <arch>       scan for "arch" (default: all architectures)
  -c, --cachedir <dir>    scan "dir" for packages. can be used more than once
                          (default: read from /etc/pacman.conf)
  -f, --force             apply force to mv(1) and rm(1) operations
  -h, --help              display this help message and exit
  -i, --ignore <pkgs>     ignore "pkgs", comma-separated. Alternatively, specify
                          "-" to read package names from stdin, newline-
                          delimited
  -k, --keep <num>        keep "num" of each package in the cache (default: 3)
      --min-atime <time>
      --min-mtime <time>  keep packages with an atime/mtime that is not older
                          than the time given, even if this means keeping more
                          than specified through the '--keep' option. Accepts
                          arguments according to 'info "Date input formats"',
                          e.g. '30 days ago'
      --nocolor           do not colorize output
  -z, --null              use null delimiters for candidate names (only with -v
                          and -vv)
  -q, --quiet             minimize output
  -u, --uninstalled       target uninstalled packages
  -v, --verbose           increase verbosity. specify up to 3 times
  -V, --version           display version information and exit

For example, I regularly remove all cached versions of packages which are no longer installed on my system:

❯ sudo paccache -rvuk0
[sudo] password for scotty: 
removed '/var/cache/pacman/pkg/qt6ct-0.11-7-x86_64.pkg.tar.zst'
removed '/var/cache/pacman/pkg/qt6ct-0.11-7-x86_64.pkg.tar.zst.sig'
removed '/var/cache/pacman/pkg/libmaa-1.5.1-1-x86_64.pkg.tar.zst'
removed '/var/cache/pacman/pkg/libmaa-1.5.1-1-x86_64.pkg.tar.zst.sig'
removed '/var/cache/pacman/pkg/libcbor-0.14.0-1-x86_64.pkg.tar.zst'
removed '/var/cache/pacman/pkg/libcbor-0.14.0-1-x86_64.pkg.tar.zst.sig'
removed '/var/cache/pacman/pkg/sequoia-sqv-1.5.0-1-x86_64.pkg.tar.zst'
removed '/var/cache/pacman/pkg/sequoia-sqv-1.5.0-1-x86_64.pkg.tar.zst.sig'
removed '/var/cache/pacman/pkg/qt5ct-1.9-2-x86_64.pkg.tar.zst'
removed '/var/cache/pacman/pkg/qt5ct-1.9-2-x86_64.pkg.tar.zst.sig'
removed '/var/cache/pacman/pkg/nettle3-3.10.2-2-x86_64.pkg.tar.zst'
removed '/var/cache/pacman/pkg/nettle3-3.10.2-2-x86_64.pkg.tar.zst.sig'
removed '/var/cache/pacman/pkg/litehtml0.9-0.9-2-x86_64.pkg.tar.zst'
removed '/var/cache/pacman/pkg/litehtml0.9-0.9-2-x86_64.pkg.tar.zst.sig'
removed '/var/cache/pacman/pkg/libjcat-0.2.6-1-x86_64.pkg.tar.zst'
removed '/var/cache/pacman/pkg/libjcat-0.2.6-1-x86_64.pkg.tar.zst.sig'
removed '/var/cache/pacman/pkg/dictd-1.13.3-1-x86_64.pkg.tar.zst'
removed '/var/cache/pacman/pkg/dictd-1.13.3-1-x86_64.pkg.tar.zst.sig'

==> finished: 9 packages removed (disk space saved: 2.41 MiB)

Manually

Pamac will install a timer which will clean the cache at regular intervals.

 $ cat /usr/lib/systemd/system/pamac-cleancache.service 
[Unit]
Description=Clean packages cache

[Service]
Type=oneshot
ExecStart=/usr/bin/pamac clean --no-confirm

But you can manually intervene using e.g.

sudo pacman -Sc

Or using pacman-contrib where the number indicates the number of versions you want to keep

sudo paccache -ruk1

Thank you ALL for your helpful replies.

The timer is, apparently, working although why I had so many very old items cached is a mystery (to me). I expected the timer to be a cron entry but ok, it seems to work, at least manually.

I’ll keep a note of your replies and check the cache regularly to check for anomalies. Again, thank you all!

I can hardly imagine a situation in which one will need 3 old versions of a package. I would set it to 1. (I have personally set it to 0, so if i need an old version i redownload it from the downgrade archive server with manjaro-downgrade).

By the way, i have a mistake in the above calculations. Those are 3 old versions. But the current version is also cached. So practically 4 +1 installed versions of everything. And if one make 1 timeshift snapshot it doubles. So from 30 gb install you get 300gb used space on disk. And from those 30 one can typically strip 5-10. I should really sit up to write this tutorial i am postponing for a third weekend…

Same here. I came to same conclusion a few years ago. I think I have needed just once or twice to downgrade a package over the years (and never anything critical). More than that I have needed to update to a version of a package not yet available in Manjaro stable, for example from unstable or from Arch directly.

It caches all previously downloaded packages.

Pacman stores its downloaded packages in /var/cache/pacman/pkg/ and does not remove the old or uninstalled versions automatically. This has some advantages:

  1. It allows downgrading a package without the need to retrieve the previous version through other means, such as the Arch Linux Archive.
  2. A package that has been uninstalled can easily be reinstalled directly from the cache directory, without requiring a new download from the repository.

However, it is necessary to deliberately clean up the cache periodically to prevent the directory from growing indefinitely in size.

The paccache(8) script, provided within the pacman-contrib package, deletes all cached versions of installed and uninstalled packages, except for the most recent three, by default:

# paccache -r