Dnf command to clean - /var/lib/dnf/plugins/local/

, ,

Is there a dnf command to clear out the old rpms from /var/lib/dnf/plugins/local/?

My system is showing rpms from F36 onwards. It had been upgraded through from F36 to F39 (current). Not sure the rpms from older releases are needed any more or the impact of manually deleting the files from the older releases.

ls -las /var/lib/dnf/plugins/local/

  1688 -rw-r--r-- 1 root root   1721610 Dec 19  2022  zfs-fuse-0.7.2.2-23.fc36.x86_64.rpm
  1696 -rw-r--r-- 1 root root   1729878 Jun 26  2023  zfs-fuse-0.7.2.2-27.fc37.x86_64.rpm
  1680 -rw-r--r-- 1 root root   1715660 Dec 10  2023  zfs-fuse-0.7.2.2-28.fc38.x86_64.rpm

Have tried the following commands (unsuccessful)

  sudo dnf clean all
  sudo dnf clean dbcache
  sudo dnf autoremove
  sudo dnf clean packages
  sudo dnf clean metadata
  sudo remove-retired-packages 36

I don’t have that directory on my F40 system, so perhaps it was created by an additional tool/plugin that you installed at some point? Either that or it was used by an older Fedora version but not anymore today:

/var/lib/dnf$ ls -la

drwxr-xr-x. 1 root root     110 Aug 19 21:06 .
drwxr-xr-x. 1 root root     922 Aug 24 10:25 ..
-rw-r--r--. 1 root root 1019904 Aug 24 12:28 history.sqlite
-rw-r--r--. 1 root root   32768 Aug 24 12:28 history.sqlite-shm
-rw-r--r--. 1 root root 5710352 Aug 24 12:19 history.sqlite-wal
drwxr-xr-x. 1 root root     158 Jul 23 11:55 repos

Most likely the package python3-dnf-plugin-local.

/etc/dnf/plugins/local.conf contains

main]
enabled = true
# Path to the local repository.
# repodir = /var/lib/dnf/plugins/local
...

If you don’t have that plugin installed, you can remove /var/lib/dnf/plugins/local/ and its contents which looks like copes of rpm files.

The dnf clean command only deals with contents of the /var/cache/dnf directory.

1 Like

Apparently that directory is obsolete and is not included in anything that fedora 40 provides. You should be able to just remove the directory and its content.

# dnf provides /var/lib/dnf/plugins/local/
Last metadata expiration check: 0:00:49 ago on Sat 24 Aug 2024 10:51:41 AM CDT.
Error: No matches found. If searching for a file, try specifying the full path or using a wildcard prefix ("*/") at the beginning.

I searched with and without the trailing / and got the same result. It also appears the /var/lib/dnf/plugins directory is obsolete as I got the same result and this is what I see on my system

# ls /var/lib/dnf
history.sqlite  history.sqlite-shm  history.sqlite-wal  repos

If you install the plugin python3-dnf-plugin-local.noarch, the plugin will create the directory /var/lib/dnf/plugins/local and starts storing rpm files there. It is correct that no package provides it, but it is not yet obsolete, although it probably will be when dnf4 becomes obsolete.

2 Likes

Thanks a bunch!! It was down to python3-dnf-plugin-local. @vekruse 's mention of the plugin jogged my memory. I do remember trying it out years ago after coming across a Fedora magazine article.

Left it installed. Have the same /etc/dnf/plugins/local.conf file.

I’ve uninstalled the plugin for now and deleted the folder /var/lib/dnf/plugins/local. Let’s see how that goes. That’s freed up a lot of disk space. Previously I was getting ‘low disk space’ warnings.

1 Like