Description of problem: When the system image had kernel-modules installed, after upgrading to the new kernel, dnf autoremove fails to clean up the old kernel and modules, raising an error: [guest@localhost ~]$ sudo dnf autoremove -y Last metadata expiration check: 0:10:27 ago on Fri 07 Dec 2018 03:07:24 PM UTC. Error: Problem: The operation would result in removing the following protected packages: kernel-core This does not happen if kernel-modules was not installed before. Version-Release number of selected component (if applicable): dnf-4.0.9-1.fc29.noarch dnf-data-4.0.9-1.fc29.noarch dnf-plugins-core-4.0.2-1.fc29.noarch dnf-yum-4.0.9-1.fc29.noarch kernel-core-4.18.16-300.fc29.x86_64 kernel-core-4.19.6-300.fc29.x86_64 kernel-modules-4.18.16-300.fc29.x86_64 kernel-modules-4.19.6-300.fc29.x86_64 libdnf-0.22.3-1.fc29.x86_64 libsolv-0.7.1-2.fc29.x86_64 How reproducible: always Steps to Reproduce: 1. Grab Fedora-Cloud-Base-29-1.2.x86_64 image 2. uname -r gives 4.18.16-300.fc29.x86_64 3. dnf install kernel-modules-4.18.16-300.fc29.x86_64 (matching running kernel) 4. dnf upgrade kernel\* -y 5. reboot 6. uname -r gives 4.19.6-300.fc29.x86_64 6. dnf autoremove -y, gives: Problem: The operation would result in removing the following protected packages: kernel-core 7. dnf remove kernel-modules-4.18.16-300.fc29.x86_64 kernel-core-4.18.16-300.fc29.x86_64 works Actual results: Expected results: the unused kernel would be autoremoved
Kernel is installonly package and therefore it is not automatically removed. The number of kept installonly packages can be set in /etc/dnf/dnf.conf with key installonly_limit. If I have installonly_limit=3 it means that 3 kernel packages will be kept on the system. Minimal number is 2 and it is for good reason. Hope that it helps.
I think there's still something fishy: [guest@localhost ~]$ sudo dnf --setopt installonly_limit=1 autoremove Last metadata expiration check: 0:07:38 ago on Mon 10 Dec 2018 03:55:06 PM UTC. Error: Problem: The operation would result in removing the following protected packages: kernel-core Any suggestions how to tell dnf autoremove to clean up unused kernel versions? Removing them manually via dnf remove works.