Bug 29943 - Impossible to limit the number of installed kernels
Summary: Impossible to limit the number of installed kernels
Status: RESOLVED DUPLICATE of bug 24403
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 8
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Mageia Bug Squad
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-25 22:31 CET by Julien Gouesse
Modified: 2022-01-25 22:47 CET (History)
1 user (show)

See Also:
Source RPM:
CVE:
Status comment:


Attachments

Description Julien Gouesse 2022-01-25 22:31:55 CET
Description of problem:
By default, performing updates and upgrades under Mageia keep all old installed kernels. Unfortunately, when there isn't enough space on the disk, Mageia fails to run and it's very difficult for beginners to understand that the problem comes from those old kernels (it happened to a friend of mine...). However, YUM and DNF are available, installonly_limit is set to 3 in etc/yum/yum.conf and in etc/dnf/dnf.conf but this setting isn't taken into account. dnf remove $(dnf repoquery --installonly --latest-limit=-2) tries to remove all kernels including the currently loaded kernel.

Version-Release number of selected component (if applicable):


How reproducible:
Every time I install a new kernel

Steps to Reproduce:
1. Install Mageia
2. Perform several updates and upgrades that bring numerous kernels
3. All kernels are kept

Workaround:
You can manually uninstall all obsolete kernels one by one with urpme. You can use my script to remove all kernels except the most recently installed kernel and the kernel currently in use:
#!/bin/bash
# script written by Julien Gouesse, under General Public License version 2
if [ ! -n "$BASH" ]
  then echo "Please run $0 with bash"
       exit 1
fi
if [ "$EUID" -ne 0 ]
  then echo "Please run $0 as root"
       exit 2
fi
kernelType=$(uname -r | cut -f 2 -d "-")
kernelReleaseNumber=$(uname -r | cut -f 1 -d "-")
kernelPatchLevelAndDistro=$(uname -r | cut -f 3 -d "-")
currentlyLoadedKernelPackagePrefix="kernel-$kernelType-$kernelReleaseNumber-$kernelPatchLevelAndDistro"
latestKernelPackagePrefix="kernel-$kernelType-latest-"
mostRecentlyInstalledKernelVirtualPackagePrefix=$(rpm -qa|grep $latestKernelPackagePrefix)
mostRecentlyInstalledKernelPackagePrefix=${mostRecentlyInstalledKernelVirtualPackagePrefix/-latest/}
packagesToDeinstall=""
for i in $(rpm -qa|grep kernel-desktop-)
do
   if [[ "$i" != *"$currentlyLoadedKernelPackagePrefix"* ]] && [[ "$i" != *"$mostRecentlyInstalledKernelVirtualPackagePrefix"* ]] && [[ "$i" != *"$mostRecentlyInstalledKernelPackagePrefix"* ]]
     then
       packagesToDeinstall+=" $i"
   fi
done
if [ "$packagesToDeinstall" == "" ] 
  then
    echo "No kernel to deinstall"
  else
    urpme $packagesToDeinstall
fi
Comment 1 sturmvogel 2022-01-25 22:39:17 CET
This is already reported. Duplicate of Bug 24403
Comment 2 Dave Hodgins 2022-01-25 22:47:53 CET
Closing as duplicate

*** This bug has been marked as a duplicate of bug 24403 ***

Resolution: (none) => DUPLICATE
Status: NEW => RESOLVED
CC: (none) => davidwhodgins


Note You need to log in before you can comment on or make changes to this bug.