The Bourne shell script code to remove the backups could be added in kernel_prerm.d_dkms (or currently non-existing kernel_postrm.d_dkms) in dkms package source, but if the package was removed, there would be no code to remove the backups in conjunction with kernel removing. Thus, the code could be added to kernel/postrm.d/initramfs-tools (or currently non-existing kernel/prerm.d/initramfs-tools) in initramfs-tools package source, too:
# This is applied from make_initrd function in dkms command, which # creates the possible initrd backup file. remove_initrd_backup() { for initrd in "initrd-$1.img" "initramfs-$1.img" "initrd.img-$1" "initrd-$1"; do rm -fv /boot/"${initrd}".old-dkms \ /boot/efi/efi/redhat/"${initrd}".old-dkms done } remove_initrd_backup "$1" -- You received this bug notification because you are a member of Kernel Packages, which is subscribed to dkms in Ubuntu. https://bugs.launchpad.net/bugs/1515513 Title: /boot/initrd.img-*.old-dkms files left behind Status in dkms package in Ubuntu: Confirmed Status in initramfs-tools package in Ubuntu: New Status in dkms package in Debian: New Bug description: One notices *.old-dkms files being left behind still sitting on the disk after purging the related kernel. This can cause /boot to become full, and when it gets really bad, even sudo apt-get autoremove won't fix the problem - only deleting the old-dkms files manually solves the problem. ProblemType: Bug DistroRelease: Ubuntu 15.04 Package: dkms 2.2.0.3-2ubuntu3.3 ProcVersionSignature: Ubuntu 3.19.0-28.30-generic 3.19.8-ckt5 Uname: Linux 3.19.0-28-generic x86_64 ApportVersion: 2.17.2-0ubuntu1.7 Architecture: amd64 CurrentDesktop: KDE Date: Thu Nov 12 08:17:10 2015 InstallationDate: Installed on 2015-05-05 (190 days ago) InstallationMedia: Ubuntu 15.04 "Vivid Vervet" - Release amd64 (20150422) PackageArchitecture: all SourcePackage: dkms UpgradeStatus: No upgrade log present (probably fresh install) To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/dkms/+bug/1515513/+subscriptions -- Mailing list: https://launchpad.net/~kernel-packages Post to : kernel-packages@lists.launchpad.net Unsubscribe : https://launchpad.net/~kernel-packages More help : https://help.launchpad.net/ListHelp