Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
31
rated 0 times [  31] [ 0]  / answers: 1 / hits: 61281  / 1 Year ago, sun, may 28, 2023, 9:58:43

I have. a simple question. After I updated my kernel, I couldn't boot (stuck on purple screen) unless I chose the old kernel. So how do I delete the new kernel with synaptic. And how do I do this safely? I'm in Quantal Quetzel. My kernel is 3.5.0-40. The working kernel is 3.5.0-39. Also, how do I stop kernel updates from appearing in the update manager? Thanks.


More From » boot

 Answers
0

If the latest kernel update break things (Original question), the best option for most is to fall back to the previous working kernel (provided that you keep at least 1 fallback option).



Otherwise, use @ZAB 's solution to install a specific version of the kernel version provided via the apt package manager.



In generic, to remove the unwanted out-dated kernels, open a terminal session and run the command:



IMPORTANT: If /boot is NOT on its tiny partition (running out of space), avoid explicitly purging old kernels. Consider them backup / fallback options when upgrade introduces problems (hardware driver modules, etc.).



Good read on kernel upgrade and preservation mechanism: How does apt on Ubuntu decide how many old kernels to keep



TL;DR: Take a look at /etc/apt/apt.conf.d/01autoremove-kernels file generated by postinstall hook (script).



Snippet from Ubuntu 20.04 LTS running 5.4.0 for a better understanding:



// DO NOT EDIT! File autogenerated by /etc/kernel/postinst.d/apt-auto-removal
APT::NeverAutoRemove
{
"^linux-.*-5.4.0-28-generic$";
"^linux-.*-5.4.0-29-generic$";
"^linux-.*-5.4.0-31-generic$";
"^kfreebsd-.*-5.4.0-28-generic$";
"^kfreebsd-.*-5.4.0-29-generic$";
"^kfreebsd-.*-5.4.0-31-generic$";
"^gnumach-.*-5.4.0-28-generic$";
"^gnumach-.*-5.4.0-29-generic$";
"^gnumach-.*-5.4.0-31-generic$";
"^.*-modules-5.4.0-28-generic$";
"^.*-modules-5.4.0-29-generic$";
"^.*-modules-5.4.0-31-generic$";
"^.*-kernel-5.4.0-28-generic$";
"^.*-kernel-5.4.0-29-generic$";
"^.*-kernel-5.4.0-31-generic$";
};


Find the kernel package name



dpkg -l | grep linux-image


At the time of writing, on amd64/x86_64 architecture the image name was: linux-image-$(uname -r)-generic



For unsigned kernel images, like those created by nvidia drivers, the image could be: linux-image-unsigned-4.20.17-042017-generic



Remove (purge - remove all configuration files as well)



sudo apt-get purge linux-image-3.5.0-40-generic


If you want to do a deep clean (leftover package configs...), USE WITH CAUTION:



dpkg -l | awk '/^rc/ { print $2 }' | xargs apt-get purge -y
dpkg -l | awk '/^rc/ { print $2 }' | xargs dpkg -P


NOTE: For Ubuntu 18.04 LTS or later, you may also want to remove any linux-modules or linux-headers packages of the same version to save disk spaces / keep you system lean.



Update - 2020-05-21



Explicitly purging old kernels may cause unexpected results. Not recommended unless /boot is on its own tiny partition (out of space).



Refer to @ZAB 's approach to get rid of the latest kernel update which introduces bug (break things).



Ubuntu wiki on Removing old kernels



There is no (I personally haven't found) easy equivalent to Fedora/RHEL/CentOS approach by setting installonly_limit=2 to tell DNF or YUM to only keep latest 2 kernels.


[#29540] Tuesday, May 30, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
itutejagua

Total Points: 89
Total Questions: 124
Total Answers: 113

Location: British Indian Ocean Territory
Member since Sun, Feb 13, 2022
2 Years ago
;