1

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

1 Answer 1

1

No linux-{image,image-extra,header}-<version>-generic package adds anything to /etc. You can confirm this using a quick check of currently installed kernel packages:

grep /etc /var/lib/dpkg/info/linux-{image,headers}*.list

The output will be nothing. This is also reinforced by the lack of .conffiles for these packages in /var/lib/dpkg/info/. As such, you don't need to purge these packages; removing and purging are effectively the same for kernel packages.

What does remain after you remove these packages is information that dpkg itself stores (in /var/lib/dpkg/info): the postrm package maintainer script, list of files, etc. The last step in purging is running postrm and deleting postrm itself (and any other information dpkg might have, such as file lists) - which is not usually done for normal removal. You might see a bunch of linux-image*.postrm files in /var/lib/dpkg/info/.

8
  • Well, at least there is a difference in status for some of these packages in the dpkg database.
    – jarno
    Commented Jan 9, 2016 at 9:12
  • That is explained in the question.
    – jarno
    Commented Jan 9, 2016 at 9:14
  • I mean packages.
    – jarno
    Commented Jan 9, 2016 at 9:14
  • No, both header packages were installed before automatic removal.
    – jarno
    Commented Jan 9, 2016 at 9:17
  • 1
    Ah, I get it. That's because the kernel image packages have package maintainer scripts (in particular, /var/lib/dpkg/info/<package-name>.postrm). The last step in purging is running postrm and deleting postrm itself (and any other information dpkg might have, such as file lists) - which is not usually done for normal removal. You might see a bunch of linux-image*.postrm files in /var/lib/dpkg/info/.
    – muru
    Commented Jan 9, 2016 at 9:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .