As installonly_limit 3 in etc/yum/yum.conf and in etc/dnf/dnf.conf didn't seem to have any effect under Mageia even by running dnf autoremove, I tried to run dnf remove $(dnf repoquery --installonly --latest-limit=-2) but it failed by complaining about being unable to remove basesystem. Actually, dnf repoquery --installonly --latest-limit=-2 seems to return all kernels including the latest kernel whatever the value of --latest-limit. What am I missing? I found this command line in this documentation, it works under some other distributions supporting DNF but not under Mageia.
dnf repoquery --installonly gives me:
kernel-desktop-5.15.11-3.mga8-0:1-1.mga8.x86_64
kernel-desktop-5.15.15-1.mga8-0:1-1.mga8.x86_64
kernel-desktop-5.15.4-1.mga8-0:1-1.mga8.x86_64
kernel-desktop-5.15.6-2.mga8-0:1-1.mga8.x86_64
dnf remove --oldinstallonly --setopt installonly_limit=1 tells me that there is no old installonly package to remove.