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:

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.

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:

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

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:

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.