View Issue Details

IDProjectCategoryView StatusLast Update
0012703CentOS-7CentOS-7-Pluspublic2017-02-24 22:29
Reportertoracat 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version7.3.1611 
Target VersionFixed in Version 
Summary0012703: Removal of a kernel-plus package fails to remove corresponding /boot/initramfs-xxxkdump.img
DescriptionOn a system where kdump is enabled, an initramfs-xxxkdump.img file is created in /boot when a new kernel package is installed and booted. Upon removal of the kernel, the .img file gets deleted.

However, with the kernel-plus package, the .img file remains untouched even when the corresponding version of kernel-plus is deleted. The reason for the failure is as follows.

The spec file of kexec-tools has this scriptlet:

================================================
%triggerpostun -- kernel kernel-xen kernel-debug kernel-PAE kernel-kdump
# List out the initrds here, strip out version nubmers
# and search for corresponding kernel installs, if a kernel
# is not found, remove the corresponding kdump initrd

#start by getting a list of all the kdump initrds
MY_ARCH=`uname -m`
if [ "$MY_ARCH" == "ia64" ]
then
    IMGDIR=/boot/efi/efi/redhat
else
    IMGDIR=/boot
fi

for i in `ls $IMGDIR/ 2>/dev/null`
do
    KDVER=`echo $i | sed -e's/^.*initramfs-//' -e's/kdump.*$//'`
    if [ ! -e $IMGDIR/vmlinuz-$KDVER ]
    then
        # We have found an initrd with no corresponding kernel
        # so we should be able to remove it
        rm -f $i
    fi
done
================================================

triggerpostun has a list of targets which, of course, does not include 'kernel-plus'.

Therefore, one easy solution to fix the issue is to add in 'kernel-plus' there. However this can only be done upstream (Red Hat).

A plausible solution will be to add the above scriptlet to the %postun section of the kernel-plus package.
TagsNo tags attached.
abrt_hash
URL

Activities

toracat

toracat

2017-01-23 17:08

manager  

centos-bug12703.patch (779 bytes)
--- kernel-plus.spec	2017-01-22 07:35:38.425844373 -0800
+++ kernel-plus.spec	2017-01-22 23:09:52.318768130 -0800
@@ -1549,6 +1549,25 @@
 fi\
 %{nil}
 
+### plus kernel mod ###
+### remove initramfs-xxxkdump.img upon kernel removal
+%postun
+# List out the initrds here, strip out version numbers
+# and search for corresponding kernel installs, if a kernel
+# is not found, remove the corresponding kdump initrd
+for i in `ls /boot/initramfs*kdump.img 2>/dev/null`
+do
+	KDVER=`echo $i | sed -e's/^.*initramfs-//' -e's/kdump.*$//'`
+	if [ ! -e /boot/vmlinuz-$KDVER ]
+	then
+		# We have found an initrd with no corresponding kernel
+		# so we should be able to remove it
+		rm -f $i
+	fi
+done
+
+### end of plus kernel mod ###
+
 %kernel_variant_preun
 %kernel_variant_post 
 
centos-bug12703.patch (779 bytes)
toracat

toracat

2017-01-23 17:08

manager   ~0028458

Patch uploaded.
toracat

toracat

2017-01-23 18:24

manager   ~0028460

The patch worked as expected.

A kernel-plus package with the patch was installed and booted (this created /boot/initramfs-xxxkdump.img). When this kernel was removed, all dangling .img files were deleted (the system had several installs of previous plus kernels).
toracat

toracat

2017-02-23 17:07

manager   ~0028673

kernel-plus-3.10.0-514.6.2.el7.centos.plus is out. It has the spec change from this bug report.

Issue History

Date Modified Username Field Change
2017-01-23 16:49 toracat New Issue
2017-01-23 16:55 toracat Status new => assigned
2017-01-23 17:08 toracat File Added: centos-bug12703.patch
2017-01-23 17:08 toracat Note Added: 0028458
2017-01-23 18:24 toracat Note Added: 0028460
2017-02-23 17:07 toracat Status assigned => resolved
2017-02-23 17:07 toracat Resolution open => fixed
2017-02-23 17:07 toracat Note Added: 0028673