So you're running Arch Linux and you enter sudo pacman -Syu to update your system, but the pacman utility says you don't have enough disk space. What happened? You likely just need to empty your system's package cache.

What Happened to My Disk Space?

If you're wondering where your disk space went, the likely culprit is Arch's package cache. Arch Linux stores a copy of each package you download in the /var/cache/pacman/pkg/ directory. This includes every package you download, even upgrades. You can roll back to previous versions in case an update breaks a package, which comes in handy on a rolling-release distro like Arch.

While having multiple copies of a package is useful for recovery, it does take up space. You might forget to remove older versions of packages. The developers of Arch Linux decided it would be better for the user to manage this cache rather than building some automatic utility to get rid of outdated versions. So how do you get your space back?

Clearing the Package Cache on Arch Linux

Fortunately, the pacman utility lets you clear away the package cache. To do that, type:

        pacman -Sc
    

This will remove any packages from the cache that are not currently installed. Adding another -c flag in the command will remove all of the cached packages.

        pacman -Scc
    

Related: How to Install and Remove Packages in Arch Linux

The paccache Utility

Cleaning the package cache with pacman is an all-or-nothing proposition. You'll want to have some older versions to fall back on while still keeping enough disk space. The paccache utility will help you balance these needs. It's part of the pacman-contrib package.

To install it, type:

        sudo pacman -S pacman-contrib
    

To remove all the cached packages except for the latest three versions, type:

        sudo paccache -r
    

If you want to keep the latest version, use the -k option, specified with the number of latest packages you want. In this case, one:

        sudo paccache -rk1
    

Related: How to Install Arch Linux in VirtualBox Using the Guided Installer

Now You Have More Disk Space

Arch takes more effort to administer than other distros. Package management is no exception, but with these tips, you can reclaim your disk space while still being able to fall back on older packages if you have to.

If you haven't tried Arch Linux yet, or if the complex installation process feels daunting to you, you can easily install Arch Linux using the guided installer.