Method to Automatically Remove Unneeded Packages?

The title kind of says it all… I’m looking for if there is a method by which I can automatically identify unnecessary, unneeded, and unused packages; e.g., I noticed during a recent update that libva-intel-media-driver was being updated, but my system has no need for anything Intel related because I am pure AMD.

Thanks for all the help!

Not an automatic way but some things to check.

To see what autoremove would get rid of
dnf list --autoremove

User installed packages sorted by date
dnf repoquery --userinstalled --qf="%{installtime} %{full_nevra}\n" | awk '{print strftime(" %F-%H:%M:%S ", $1)"\t" $2}' | sort -r -h

Also not automatic, but rpmreaper will help to identify “leaf” packages that no other package depends on and which can (probably) be removed without much consequence. It also has a quick way of getting summaries of what various packages are as you navigate through them (press the i key).

1 Like

This is a cool tool Thanks!!!

I “autoremove” pretty regularly and think that’s a great suggestion; I also think rpmreaper is a cool tool and need to learn more about it.

I’m not sure either of those suggestions actually addresses what I’m getting at, so I don’t think I was clear…

In my mind, I’m imagining (read: hoping) there is a tool that will use my current system configuration and identify those packages that are installed that aren’t necessarily “compatible.” For example, the tool will identify that I don’t have any Intel parts and recommend all the Intel packages that were installed at any point for removal.

Hardware firmware is installed by defaiult. In that way it makes it possible to ungrade your hardware and keep working. It also makes it possible to move the disk to a new system.

As the packages take up little space on my disks I’ve not been interested in remove these types of packages.

I’m pretty sure unnecessary firmware was being put into initramfs (longer generation, slower boot); I think omitting through dracut.conf would work vs removing packages, but I did this on an all-Intel laptop:

sudo dnf remove 'amd-gpu-firmware' 'nvidia-gpu-firmware' 'atheros-firmware' 'mt7xxx-firmware'

I was surprised to see Anaconda installer stuff present post-install, and don’t do anything with virtualization (iirc there’s a lot of unnecessary dependencies):

sudo dnf remove libvirt-client anaconda-*

what if you did it with an excludes drop in file …

/etc/dnf/libdnf5.conf.d/90-unwantedpkgs.conf

[main]
excludepkgs="akmod-nvidia, akmod-nvidia-390xx, akmod-nvidia-470xx"

and then just used something like ..

#!/usr/bin/env bash
UNWANTEDPKGS="$(sed -e '1d' -e 's/"//g' -e 's/,//g' -e's/excludepkgs=//' /etc/dnf/libdnf5.conf.d/90-unwantedpkgs.conf)"
for pkg in ${UNWANTEDPKGS}
do
  echo "${pkg}"
  dnf --exclude="" list --installed "${pkg}"
done 

Both of those ideas sound interesting… Since it looks like I’d be setting up my own scripts and/or altering the way dnf behaves, it sounds like there is not an already existing tool like that which I described.