Hi, I'm Sam Parkinson

Freeing Disk Space with the PackageKit cache

Automatic updates gone wrong

By Sam Parkinson, 30 April 2017; view other posts

So the Fedora 26 Alpha was recently released. Logically it follows that I need to update my laptop right now! So that's what I did, I ran sudo dnf system-upgrade download --releasever 26, and off it went:

Error Summary
Disk Requirements:
   At least 1135MB more space needed on the / filesystem.

Well that's exciting.

Diagnosing the problem

There are so many great tools to debug disk usage on GNU/Linux. NCurses Disk Usage is one of may favourite tools to use from the command line. But GNOME's Disk Usage Analyzer (or Baobab) is just a little more photogenic:

Baobab screenshot

Time to do the Tango!

So PackageKit huh? Using 16 gigabytes of disk space?!?!

Well, these files are used by the Offline Update functionality of PackageKit. GNOME Software automatically downloads updates, then you can click "Restart and Install" and updates are installed when the system is not running ("offline"). You can read more about it from hughsie's blog.

Unfortunately; PackageKit assumes that it is the only way you update your computer. If an update is not applied via PackageKit, it is not deleted. This means if you use dnf update, the auto-downloaded packages are not deleted. Eventually you disk space usage can spiral out of control; as mine has. That explains why PackageKit is still caching updates from Fedora 24, despite how I haven't run that version for the last 6 months!

Safely removing the package kit cache

PackageKit does not offer a built in way to clean the updates. So we have to resort to a dumb fix.

First delete the whole cache directory:

rm -r /var/cache/PackageKit

Then for cleanliness, let PackageKit re-download the metadata cache. This just downloads the metadata cache; not the auto updates:

sudo pkcon refresh force -c -1

That made my PacakageKit directory go from 16G to a small 75M; a saving of 15.9 gigabytes!

The Shadow package manager

Fedora (and probably other distros) are in an interesting place now. PackageKit is slowly but surely duplicating the built-in package manager functionality. I'm not sure what to think about this change. It brings so many UX improvements, like suggesting packages when I type a command:

Terminal screenshot

It also provides GNOME Software, Flatpak integration and more. But having package managers fight over control of the same packages seems like a bad thing.

I don't know. What do you think? Make sure to email us or reach out to us on Twitter with your thoughts!

Comments, thoughts? Mail them to [email protected]. I would love to hear them!

Related posts

View all posts
Arithmetic with JavaScript Arrays
A Astonishing Adventure
Read post
Keeping Python projects secure on GitLab
Pinning projects to the very latest
Read post
Derivations 102 - Learning Nix pt 4
Taking advantage of the fact Nix is a programming language
Read post
Creating a super simple derivation - Learning Nix pt 3
Wrapping some shell scripts
Read post
So Variables are a Thing - Learning Nix pt 2
Taking advantage of the fact Nix is a programming language
Read post
NSDC 2016 Topics
Digitizing the motions from National Schools Debating Championships 2016
Read post