Is there any use in purging a kernel package, instead of removing? I ask this, because automatic removal of packages does not purge all packages it removes. (I have setup this automatic removing in /etc/apt/apt.conf.d/50unattended-upgrades, and it is said to be equivalent to apt-get autoremve) At least dpkg-query -L for such a package gives
Package 'linux-image-4.2.0-21-generic' does not contain any files (!)
so it would suggest there are no config files lying around. dpkg-query shows status deinstall ok config-files for linux-image-4.2.0-21-generic. For the respective header package linux-headers-4.2.0-21-generic, dpkg-query shows status not-installed, and for linux-headers-4.2.0-21 it does not show a match after the automatic removal operation.
For what it is worth, here is an extract of /var/log/unattended-upgrades/unattended-upgrades-dpkg.log:
Removing linux-headers-4.2.0-21-generic (4.2.0-21.25) ...
Removing linux-headers-4.2.0-21 (4.2.0-21.25) ...
Removing linux-image-extra-4.2.0-21-generic (4.2.0-21.25) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.2.0-21-generic /boot/vmlinuz-4.2.0-21-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.2.0-21-generic /boot/vmlinuz-4.2.0-21-generic
Error! Your kernel headers for kernel 4.2.0-21-generic cannot be found.
Please install the linux-headers-4.2.0-21-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
Error! Your kernel headers for kernel 4.2.0-21-generic cannot be found.
Please install the linux-headers-4.2.0-21-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.2.0-21-generic /boot/vmlinuz-4.2.0-21-generic
update-initramfs: Generating /boot/initrd.img-4.2.0-21-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.2.0-21-generic /boot/vmlinuz-4.2.0-21-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.2.0-21-generic /boot/vmlinuz-4.2.0-21-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.2.0-21-generic /boot/vmlinuz-4.2.0-21-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.2.0-21-generic /boot/vmlinuz-4.2.0-21-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.2.0-23-generic
Found initrd image: /boot/initrd.img-4.2.0-23-generic
Found linux image: /boot/vmlinuz-4.2.0-22-generic
Found initrd image: /boot/initrd.img-4.2.0-22-generic
Found linux image: /boot/vmlinuz-4.2.0-21-generic
Found initrd image: /boot/initrd.img-4.2.0-21-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 7 (loader) on /dev/sda1
done
Removing linux-image-4.2.0-21-generic (4.2.0-21.25) ...
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/dkms 4.2.0-21-generic /boot/vmlinuz-4.2.0-21-generic
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.2.0-21-generic /boot/vmlinuz-4.2.0-21-generic
update-initramfs: Deleting /boot/initrd.img-4.2.0-21-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.2.0-21-generic /boot/vmlinuz-4.2.0-21-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.2.0-23-generic
Found initrd image: /boot/initrd.img-4.2.0-23-generic
Found linux image: /boot/vmlinuz-4.2.0-22-generic
Found initrd image: /boot/initrd.img-4.2.0-22-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 7 (loader) on /dev/sda1
done