Old kernels no longer automtically removed

Ubuntu Version:
20.04 LTS

Problem Description:
I have been using 20.04 for over 4 years. Whenever software updater informs me of a new kernel, I always accept it, and usually that is followed by a further request to remove old kernel versions, which I also accept (it usually leaves the new and previous ones).

However, for the last 6 kernel updates I have no longer received a request to remove the old versions. Is there any reason for this? (See current list of kernels below)

I am intending to install 24.04 soon, but would like to leave 20.04 in place ‘just in case’, so would like to tidy it up.

reg:~$ uname -r
5.4.0-208-generic
reg:~$ ls -l /boot
total 585948
-rw-r--r-- 1 root root   237778 Aug  2  2024 config-5.4.0-195-generic
-rw-r--r-- 1 root root   237778 Aug 29  2024 config-5.4.0-196-generic
-rw-r--r-- 1 root root   237778 Sep 27 17:59 config-5.4.0-198-generic
-rw-r--r-- 1 root root   237778 Sep 27 13:40 config-5.4.0-200-generic
-rw-r--r-- 1 root root   237778 Nov  8 14:14 config-5.4.0-202-generic
-rw-r--r-- 1 root root   237778 Dec  5 11:35 config-5.4.0-204-generic
-rw-r--r-- 1 root root   237778 Jan 10 21:28 config-5.4.0-205-generic
-rw-r--r-- 1 root root   237889 Feb  7 17:31 config-5.4.0-208-generic
drwx------ 6 root root     4096 Jan  1  1970 efi
drwxr-xr-x 5 root root     4096 Feb 25 09:12 grub
lrwxrwxrwx 1 root root       28 Feb 25 09:12 initrd.img -> initrd.img-5.4.0-208-generic
-rw-r--r-- 1 root root 55816141 Sep 11  2024 initrd.img-5.4.0-195-generic
-rw-r--r-- 1 root root 55816157 Oct 12 20:06 initrd.img-5.4.0-196-generic
-rw-r--r-- 1 root root 55816238 Oct 21 15:43 initrd.img-5.4.0-198-generic
-rw-r--r-- 1 root root 55835250 Dec 11 10:03 initrd.img-5.4.0-200-generic
-rw-r--r-- 1 root root 55835644 Dec 13 09:13 initrd.img-5.4.0-202-generic
-rw-r--r-- 1 root root 55835689 Dec 17 14:27 initrd.img-5.4.0-204-generic
-rw-r--r-- 1 root root 57379340 Feb 18 12:21 initrd.img-5.4.0-205-generic
-rw-r--r-- 1 root root 57379956 Feb 25 09:12 initrd.img-5.4.0-208-generic
lrwxrwxrwx 1 root root       28 Feb 25 09:12 initrd.img.old -> initrd.img-5.4.0-205-generic
-rw-r--r-- 1 root root   182704 Aug 18  2020 memtest86+.bin
-rw-r--r-- 1 root root   184380 Aug 18  2020 memtest86+.elf
-rw-r--r-- 1 root root   184884 Aug 18  2020 memtest86+_multiboot.bin
-rw------- 1 root root  4761900 Aug  2  2024 System.map-5.4.0-195-generic
-rw------- 1 root root  4761900 Aug 29  2024 System.map-5.4.0-196-generic
-rw------- 1 root root  4761900 Sep 27 17:59 System.map-5.4.0-198-generic
-rw------- 1 root root  4762321 Sep 27 13:40 System.map-5.4.0-200-generic
-rw------- 1 root root  4762385 Nov  8 14:14 System.map-5.4.0-202-generic
-rw------- 1 root root  4762473 Dec  5 11:35 System.map-5.4.0-204-generic
-rw------- 1 root root  4762524 Jan 10 21:28 System.map-5.4.0-205-generic
-rw------- 1 root root  4766192 Feb  7 17:31 System.map-5.4.0-208-generic
lrwxrwxrwx 1 root root       25 Feb 25 09:12 vmlinuz -> vmlinuz-5.4.0-208-generic
-rw------- 1 root root 13701896 Aug  2  2024 vmlinuz-5.4.0-195-generic
-rw------- 1 root root 13701896 Aug 29  2024 vmlinuz-5.4.0-196-generic
-rw------- 1 root root 13701896 Sep 27 18:25 vmlinuz-5.4.0-198-generic
-rw------- 1 root root 13701896 Sep 27 13:56 vmlinuz-5.4.0-200-generic
-rw------- 1 root root 13705992 Nov  8 14:31 vmlinuz-5.4.0-202-generic
-rw------- 1 root root 13705992 Dec  5 11:37 vmlinuz-5.4.0-204-generic
-rw------- 1 root root 13705992 Jan 10 21:40 vmlinuz-5.4.0-205-generic
-rw------- 1 root root 13710088 Feb  7 17:53 vmlinuz-5.4.0-208-generic
lrwxrwxrwx 1 root root       25 Feb 25 09:12 vmlinuz.old -> vmlinuz-5.4.0-205-generic

If you open a terminal and type: sudo apt autoremove
and then press enter, the system will delete any that are not required.

1 Like

OK, thanks, but I was wondering if there is any way to reinstate the previous behaviour of the software updater?

man apt.conf

I think this is the setting you might be looking for?

NeverAutoRemove::KernelCount

1 Like

@regub , could you please try this and post the output? If you don’t want to actually autoremove kernels by this method, running it only as simulation should get enough information:

apt -s autoremove

If this method does not see the “extra” kernels as autoremovable, neither will Software Updater.

If apt autoremove doesn’t remove old versions try this one:

sudo apt install byobu
sudo purge-old-kernels

This utility removes old kernels and only keeps currently running kernel and one or two previous versions

This topic was automatically closed after 30 days. New replies are no longer allowed.