PDA

View Full Version : 20.04 Desktop - Retaining additional kernel versions



davehk
January 13th, 2021, 01:10 PM
Previous versions of Ubuntu used to keep about 4 versions of the kernel, so there were alternatives if a kernel update cause a problem. The default installation of 20.04 LTS Desktop version on keeps 2 - the newly installed version and the version that was running when the update was done.

This has recently resulted in a problem with both Ubuntu's version of VirtualBox (and i believe Nvidia drivers, but I don't use those) with kernel 5.8.0-xx-generic, as the update "breaks" both of these. One solution suggested to me was to boot using the kernel 5.4 - but all I have on the system is 5.8.0-34 and -36.

I know that there is a way to tell apt (I think) to keep more than those, but I cannot find any instructions on how to do it. Plenty of info on how to remove older kernels (as they used to pile up with earlier releases), but none on how to keep them.

I'd be grateful if someone could point me in the right direction.

Thanks.

TheFu
January 13th, 2021, 02:11 PM
Use apt-mark to tell APT to 'hold' any package you don't want removed.

davehk
January 13th, 2021, 02:33 PM
Use apt-mark to tell APT to 'hold' any package you don't want removed.

Thanks, that will allow me to retain specific versions. But it used to be possible to retain the last n kernels, regardless of version.

EDIT: I think I've found it:

In /etc/kernel/postinst.d/apt-auto-removal

change

previous_version="$(echo "$debverlist" | sed -n 2p)" to

previous_version="$(echo "$debverlist" | sed -n 2,4p)"

I actually had it bookmarked from askubuntu but missed it.

grahammechanical
January 14th, 2021, 12:58 AM
If I understand things correctly, Software Updater removes older kernels when a new one has been installed. But apt update/upgrade does not. We have to use apt autoremove or run Software Updater to remove older kernels.

Regards