57

I noticed that the folder referenced in the subject line is taking up 1.5 GB. Can I run the below to clear it without causing permanent damage to my system?

rm -rf /var/cache/PackageKit/metadata/updates/packages/*
74

From the discussion in the bug linked in Daniel Bruno's answer .. you can get rid of these files using PackageKit console client pkcon

$ sudo pkcon refresh force -c -1

It takes some time but is provided by PackageKit itself. (and you may set a cron job for it)

from the man page of pkcon(1)

   refresh [force]
       Refresh the cached information about available updates.

and

   -c, --cache-age AGE
       Set the maximum acceptable age for cached metadata, in seconds. Use -1 for 'never'.

So this tells PackageKit to delete cached information (refresh cached information with maximum acceptable age of : never)

References :

  • 1
    What does this command do? – anatoly techtonik Jul 14 '16 at 10:37
  • 1
    @anatoly Answer updated to show a basic description of command from man page pkcon(1) – Mahmoud Mostafa Jul 26 '16 at 13:37
  • 1
    @erik edited to show reference links – Mahmoud Mostafa Sep 8 '16 at 13:25
  • 2
    So I ran the command in the answer and it chugged away for awhile but I was still left with over 3.5 GB used in my /var/cache/PackageKit directory. What am I missing? – Mark Edington Jan 21 '17 at 14:44
  • 5
    The pkcon command as given will not remove downloaded packages that have been cached. The problem is worse if you have a system that has been through multiple upgrades of the OS. In my case I've gone from Fedora 23->24->25. I've also used dnf quite a bit too. I have 3 additional directories (23, 24, 25)) under the /var/cache/PackageKit that all contain rpm files. I think my only real option here is manual deletion at this point. – Mark Edington Jan 21 '17 at 15:01
17

PackageKit is used by GNOME. If you use Yum or DNF on the CLI then don't need these. You can remove the .rpm files in /var/cache/PackageKit/metadata/updates/packages and set PackageKit to not store them any longer.

There is a setting in the file /etc/PackageKit/PackageKit.conf

# Keep the packages after they have been downloaded
#KeepCache=false

As root, remove the hash mark on this configuration option and the packages will not be saved.

  • 3
    If you have upgraded from previous release of the OS, like Fedora 23->24->25 you'll also need to delete RPMs in numbered cache directory like these: /var/cache/PackageKit/24 /var/cache/PackageKit/23 /var/cache/PackageKit/25 – Mark Edington Jan 21 '17 at 15:07
  • 1
    The idea seems to come from this comment on the fedora mailing list. But it is not effective, i.e. my /var/cache/PackageKit directory is still growing. That means: Does not work neither on Fedora 24, and as of Thomas Mueller, nor on Fedora 25. – erik Jan 22 '17 at 8:23
15

Yes, you can safely remove these packages. These packages are only used as cache by Packagekit.

Ref: https://bugs.freedesktop.org/show_bug.cgi?id=80053

  • 1
    See this bug: bugzilla.redhat.com/show_bug.cgi?id=1306992 – erik Sep 5 '16 at 16:37
  • 4
    It seems this is the only way to remove packages from /var/cache/PackageKit/24 or /var/cache/PackageKit/25 directories after upgrade to Fedora 26. pkcon from accepted answer does not remove them. – ks1322 Sep 11 '17 at 15:40
  • 1
    Yes. I found I had cache from Fedora 23 - 27, and hawkey. Running the command in the pkcon seemed to drop the usage from 23 GB to 20 GB. So instead I ended doing a rm -rf and then ran the pkcon command to makes sure package kit had the minimum it needed to work. – user6856 Nov 20 '17 at 13:49
12

if not using PackageKit to update (but dnf) one should consider disabling PackageKit auto-download, because PackageKit will only clear its cache when using it to install updates:

gsettings set org.gnome.software download-updates false

I think this auto-download should be opt-in instead of opt-out.

https://www.lguruprasad.in/blog/2015/05/13/disabling-automatic-download-of-software-updates-in-gnome-3-14-on-debian-jessie/

https://bugzilla.gnome.org/show_bug.cgi?id=768632

  • I will try this one. Let’s see if it works. I did this with sudo, i.e. as user root. – erik Jan 22 '17 at 8:07
7

The pkcon refresh force -c -1 solution didn't work for me since there was multiple Fedora versions in the wake in my upgrade path. I solved the space issue constructively by dnf clean all --releasever=xxx where xxx is the old version that needed cleaned out. It cleaned out about 8 Gig of space for the previous version.

2

The pkcon refresh [force] command given in the accepted answer works, but, importantly, only for currently enabled repositories. It doesn't delete no longer needed files in the caches for older repositories, most notably for old distribution versions. Those can be safely deleted manually. (If you really want to delete them using pkcon, then some manner of pkcon repo-enable [reponame]; pkcon fresh force; pkcon repo-disable [reponame] can work.)

0

I was getting storage space warnings when booting Fedora25 on my virtual machine. I followed the aforementioned solution to edit the /etc/PackageKit/PackageKit.conf file and uncommented the #KeepCache=false line and saved the file. Then I ran the following cmd: pkcon refresh force -c -1 but there were still unwanted files in /var/cache/PackageKit/ so i ran rm -r -f /var/cache/PackageKit/* at the command line to delete these cached files. I restarted Fedora and Voila! No more errors!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.