Closed hboetes closed 1 year ago
For dnf the syntax has to be changed from /usr/bin/package-cleanup --oldkernels --count=2 -y
to /bin/dnf remove -y $(/bin/dnf repoquery --installonly --latest-limit=-2)
Unfortunately
/bin/dnf remove -y $(/bin/dnf repoquery --installonly --latest-limit=-1
fails for the case when the latest kernel is not running:
# rpm -q kernel && uname -r
kernel-5.14.0-162.23.1.el9_1.x86_64
kernel-5.14.0-284.11.1.el9_2.x86_64
5.14.0-162.23.1.el9_1.x86_64
results in
# /bin/dnf remove -y $(/bin/dnf repoquery --installonly --latest-limit=-1)
Error:
Problem: The operation would result in removing the following protected packages: kernel-core
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
dnf remove $(/bin/dnf repoquery --installonly --latest-limit=-1 | grep -v $(facter kernelrelease))
to exclude running kernel...
Though part of me thinks this is all a bit scary and better to just wait for the next kernel update - it has an option for that however.
For efficiency’s sake, please consider using $(uname -r)
instead.
% time facter kernelrelease
6.2.15-300.fc38.x86_64
facter kernelrelease 0.14s user 0.04s system 101% cpu 0.174 total
time uname -r
6.2.15-300.fc38.x86_64
uname -r 0.00s user 0.00s system 73% cpu 0.001 total
package-cleanup
uses a wrong syntax, resulting in this error messageFrom the cli it looks like this: