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/*
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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 :
- https://bugs.freedesktop.org/show_bug.cgi?id=80053#c6
- https://bugzilla.redhat.com/show_bug.cgi?id=1306992#c10
Method 2
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.
Method 3
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
Method 4
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://bugzilla.gnome.org/show_bug.cgi?id=768632
Method 5
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.
Method 6
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.)
Method 7
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!!
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0