How to remove older kernel

After this morning sudo apt full-upgrade I have:

purism@pureos:~$ apt list --installed 2>/dev/null | grep '^linux-image-.*-librem5'
linux-image-5.18.0-1-librem5/now 5.18.11pureos1 arm64 [installed,local]
linux-image-6.0.0-1-librem5/byzantium,now 6.0.8pureos1 arm64 [installed,automatic]
purism@pureos:~$ sudo apt autoremove
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Should I remove the 5.18.x kernel? And how?

I think you can just do “apt remove” on it: apt remove linux-image-5.18.0-1-librem5

But I think it does not hurt to leave it there, it just takes some disk space.

1 Like

Thanks. The problem is, that the partition /boot is only 451M in size and the two Linux images occupy there already 44%. That’s why I’m keen to freeing up disk space there.

2 Likes

OK. My understanding of these things is that it should be fine to remove all kernels except one, the one that is actually used. You can check which one is used right now using the “uname -a” command.

One thing to be careful about is that if you have just installed some new kernel package and not yet rebooted, then “uname -a” will still show the kernel running now (the old one), which is then not the same as the kernel that will be running after next reboot. So, best to reboot first, then check with “uname -a” which kernel is used, then remove other kernels if you want/need to do that.

1 Like

I see older kernels removed by being promoted it to Brigadier General or forced retirement if passed over too many times for promotion.

2 Likes

I think PureOS is set to leave only one kernel behind on upgrades. So if the kernel were to be updated again it will remove the 5.x kernel and leave the 6.0 one you have now. Thaf’s in case there’s a problem with a kernel update than you have a backup one you can use.

2 Likes

Correct, PureOS works as it should. It is on user to execute: sudo apt autoremove, in order solve @guru issue, every time when new Linux kernel upgrade installed. Nothing else needed, after reboot, as @Skalman already recommended in his post.

1 Like

sudo apt autoremove --purge

What about the ones left on the bottom of the bowl? What to do?

1 Like

Yes, thanks! Related obsolete Linux kernel removal looks just about perfect now:

FWIW autoremove does not take package name arguments - you use it by just invoking sudo apt autoremove (and optionally --purge). If you add arguments, it acts just like remove.

1 Like

residual-config file was only leftover after sudo apt autoremove. Now it is gone as well.

EDIT: