I have like 7 kernels and during upgrade it takes a lot of time to set them up...Is there a way to delete older kernels ?
Announcement
Collapse
No announcement yet.
How do I remove the old kernels ?
Collapse
This topic is closed.
X
X
-
Open a terminal window and type sudo apt autoremove
It will remove old kernels and also other old leftover packages that are out of date after they were updated.Je suis Charlie, how many more people have to die for religions
linux user #447706 on https://linuxcounter.net
A good place to start: Topic: Top 20 Kubuntu FAQs & Answers
- Top
- Bottom
Comment
-
If your system is working correctly and you're updating the normal way (using apt full-upgrade, pkcon, or the update tool), the update should leave behind one previous kernel along with the current - meaning autoremove will only remove all the the last two kernels. The exception is if you switch to a different kernel series - like you're using 5.0.0 and you install 5.4.0. Then autoremove will leaving behind the last 5.0.0 kernel requiring you to manually remove it.
So what kernels are remaining will dictate how you have to proceed.
- Top
- Bottom
Comment
-
sudo apt autoremove does not remove older kernels:
l3gi0n@Diophantus:~$ dpkg --list | grep linux-image
rc linux-image-5.4.0-26-generic 5.4.0-26.30 amd
64 Signed kernel image generic
ii linux-image-5.4.0-28-generic 5.4.0-28.32 amd
64 Signed kernel image generic
ii linux-image-5.4.0-29-generic 5.4.0-29.33 amd
64 Signed kernel image generic
ii linux-image-5.4.0-31-generic 5.4.0-31.35 amd
64 Signed kernel image generic
ii linux-image-5.4.0-33-generic 5.4.0-33.37 amd
64 Signed kernel image generic
ii linux-image-5.4.0-40-generic 5.4.0-40.44 amd
64 Signed kernel image generic
ii linux-image-5.4.0-42-generic 5.4.0-42.46 amd
64 Signed kernel image generic
ii linux-image-5.4.0-47-generic 5.4.0-47.51 amd
64 Signed kernel image generic
ii linux-image-generic 5.4.0.47.50 amd
64 Generic Linux kernel image
l3gi0n@Diophantus:~$ sudo apt autoremove
[sudo] password for l3gi0n:
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
should i use something like: sudo purge-old-kernels --keep 2Last edited by Modularity; Sep 18, 2020, 04:39 PM.
- Top
- Bottom
Comment
-
More Info:
l3gi0n@Diophantus:~$ apt-mark showmanual 'linux-image-.*'
linux-image-5.4.0-28-generic
linux-image-5.4.0-29-generic
linux-image-5.4.0-31-generic
linux-image-5.4.0-33-generic
linux-image-5.4.0-40-generic
l3gi0n@Diophantus:~$ apt-mark showauto 'linux-image-.*'
linux-image-5.4.0-42-generic
linux-image-5.4.0-47-generic
linux-image-generic
- Top
- Bottom
Comment
-
I now use the Ubuntu Mainline Kernel Installer which is a fork of the older UKUU utility.
You can find it via a websearch.
It is a kernel maintenance utility and will let you install/remove/purge Linux kernels.Kubuntu 24.11 64bit under Kernel 6.11.4, Hp Pavilion, 6MB ram. Stay away from all things Google...
- Top
- Bottom
Comment
-
Originally posted by Modularity View Postshould i use...
If they're not there, something's gone wrong and you'd have to find the kernels and their baggage and delete them manually. Ask here if you'd like help with that.
I use an updated driver for the ethernet chip on my motherboard (the one in Ubuntu is 5 years old) and prior to 20.04 I had various problems with dkms, and this sometimes screwed up the purging of old kernels, so I had to delete lots of stuff, very carefully.Regards, John Little
- Top
- Bottom
Comment
-
autoremove will only remove a kernel if it's of the current series and just became the third oldest one. If you skip automove after installing a kernel, autoremove skips it too.
Code:stuart@office:~$ ll /boot |grep vmlinuz-5.4.0 lrwxrwxrwx 1 root root 24 Sep 13 14:10 vmlinuz -> vmlinuz-5.4.0[COLOR=#000000]-47-generic -rw------- 1 root root 11670272 Aug 26 09:19 vmlinuz-5.4.0-45-generic -rw------- 1 root root 11670272 Sep 4 15:18 vmlinuz-5.4.0-47-generic lrwxrwxrwx 1 root root 24 Sep 13 14:10 vmlinuz.old -> vmlinuz-5.4.0[/COLOR]-45-generic
Code:stuart@office:~$ cat /etc/apt/apt.conf.d/01autoremove-kernels // DO NOT EDIT! File autogenerated by /etc/kernel/postinst.d/apt-auto-removal APT::NeverAutoRemove { "^linux-.*-5\.4\.0-45-generic$"; "^linux-.*-5\.4\.0-47-generic$"; "^kfreebsd-.*-5\.4\.0-45-generic$"; "^kfreebsd-.*-5\.4\.0-47-generic$"; "^gnumach-.*-5\.4\.0-45-generic$"; "^gnumach-.*-5\.4\.0-47-generic$"; "^.*-modules-5\.4\.0-45-generic$"; "^.*-modules-5\.4\.0-47-generic$"; "^.*-kernel-5\.4\.0-45-generic$"; "^.*-kernel-5\.4\.0-47-generic$"; }; /* Debug information: # dpkg list: rc linux-image-4.15.0-42-generic 4.15.0-42.45 amd64 Signed kernel image generic rc linux-image-4.15.0-44-generic 4.15.0-44.47 amd64 Signed kernel image generic rc linux-image-4.15.0-45-generic 4.15.0-45.48 amd64 Signed kernel image generic rc linux-image-4.18.0-15-generic 4.18.0-15.16~18.04.1 amd64 Signed kernel image generic rc linux-image-4.18.0-16-generic 4.18.0-16.17~18.04.1 amd64 Signed kernel image generic rc linux-image-4.18.0-17-generic 4.18.0-17.18~18.04.1 amd64 Signed kernel image generic rc linux-image-4.18.0-18-generic 4.18.0-18.19~18.04.1 amd64 Signed kernel image generic rc linux-image-4.18.0-20-generic 4.18.0-20.21~18.04.1 amd64 Signed kernel image generic rc linux-image-4.18.0-21-generic 4.18.0-21.22~18.04.1 amd64 Signed kernel image generic rc linux-image-4.18.0-22-generic 4.18.0-22.23~18.04.1 amd64 Signed kernel image generic rc linux-image-4.18.0-24-generic 4.18.0-24.25~18.04.1 amd64 Signed kernel image generic rc linux-image-4.18.0-25-generic 4.18.0-25.26~18.04.1 amd64 Signed kernel image generic rc linux-image-5.0.0-23-generic 5.0.0-23.24~18.04.1 amd64 Signed kernel image generic rc linux-image-5.0.0-25-generic 5.0.0-25.26~18.04.1 amd64 Signed kernel image generic rc linux-image-5.0.0-29-generic 5.0.0-29.31~18.04.1 amd64 Signed kernel image generic rc linux-image-5.0.0-31-generic 5.0.0-31.33~18.04.1 amd64 Signed kernel image generic rc linux-image-5.0.0-32-generic 5.0.0-32.34~18.04.2 amd64 Signed kernel image generic rc linux-image-5.0.0-37-generic 5.0.0-37.40~18.04.1 amd64 Signed kernel image generic rc linux-image-5.3.0-46-generic 5.3.0-46.38~18.04.1 amd64 Signed kernel image generic rc linux-image-5.3.0-51-generic 5.3.0-51.44~18.04.2 amd64 Signed kernel image generic rc linux-image-5.3.0-53-generic 5.3.0-53.47~18.04.1 amd64 Signed kernel image generic ii linux-image-5.3.0-62-generic 5.3.0-62.56~18.04.1 amd64 Signed kernel image generic ii linux-image-5.4.0-42-generic 5.4.0-42.46 amd64 Signed kernel image generic ii linux-image-5.4.0-45-generic 5.4.0-45.49 amd64 Signed kernel image generic iF linux-image-5.4.0-47-generic 5.4.0-47.51 amd64 Signed kernel image generic ii linux-image-generic 5.4.0.47.50 amd64 Generic Linux kernel image # list of installed kernel packages: 5.3.0-62-generic 5.3.0-62.56~18.04.1 5.4.0-42-generic 5.4.0-42.46 5.4.0-45-generic 5.4.0-45.49 5.4.0-47-generic 5.4.0-47.51 # list of different kernel versions: 5.4.0-47.51 5.4.0-45.49 5.4.0-42.46 5.3.0-62.56~18.04.1 # Installing kernel: 5.4.0-47.51 (5.4.0-47-generic) # Running kernel: 5.4.0-45.49 (5.4.0-45-generic) # Last kernel: 5.4.0-47.51 # Previous kernel: 5.4.0-45.49 # Kernel versions list to keep: 5.4.0-45.49 5.4.0-47.51 # Kernel packages (version part) to protect: 5\.4\.0-45-generic 5\.4\.0-47-generic */
Last edited by oshunluvr; Apr 05, 2022, 12:02 PM.
- Top
- Bottom
Comment
-
I know that some people don't like it but Ubuntu-cleaner will remove old kernels. I've used it many times and never had a problem with it.
you can get it here.Dave Kubuntu 20.04 Registered Linux User #462608
Wireless Script: http://ubuntuforums.org/showthread.p...5#post12350385
- Top
- Bottom
Comment
-
I know that some people don't like it but Ubuntu-cleaner will remove old kernels. I've used it many times and never had a problem with it.
you can get it from here: https://www.omgubuntu.co.uk/2016/12/...o%20BleachBit.Dave Kubuntu 20.04 Registered Linux User #462608
Wireless Script: http://ubuntuforums.org/showthread.p...5#post12350385
- Top
- Bottom
Comment
-
From various previous discussions of this subject, I copied-saved these notes on manually cleaning old kernels. Sorry, I don't have time to clean it up at the moment, but I think it's in pretty decent shape as is (fwiw, this is what I do -- I simply use Muon as described here):
Removing old kernels
Every kernel has four packages (kernel 3.5.0-15 is shown as an example); and these are the files (for old kernels) that you want to remove:
linux-headers-3.5.0-15 (header files)
linux-headers-3.5.0-15-generic (additional headers depending on kernel type)
linux-image-3.5.0-15-generic (kernel image) <-- Important
linux-image-extra-3.5.0-15-generic (extra image)
Once you have installed a new kernel and booted into it to see that it's working properly, you can remove all packages related to older kernels - generally around 220 MB for all packages together per kernel. However, you may want to keep the kernel version previous to the newest (that you are using now) so you have a backup option should something go wrong with the current (newest) kernel.
In Muon (or Synaptic), you can enter in the search box:
linux-image
linux-headers
Or, try this:
Simply enter the kernel version number; for example, enter
3.13.0
and the headers and image files should come up.
You can now uninstall all packages except those four for the latest kernel (and maybe the four files for the previous kernel, if you want a backup option).
Un-installing
Some users here (e.g., vinny and I) recommend you use the "purge" option (in Muon, for example), to remove these files.
Someone else said:
> Remove the linux-image-VERSION-generic packages and it will also remove the modules for you.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
re commands, I have this:
Remove old kernels -- using apt-get
Do the following if you wish to remove all older kernel versions that are not in use (except the previous one that you are not using. This is to make sure that if the current kernel version fails in some way, you have a way to go back to a previous state). Do the following:
Code:
sudo apt-get autoclean
Code:
sudo apt-get autoclean
(Correction: kubicle): autoclean is just a "softer" version of 'clean', removing old packages from the download cache, keeping still available packages in cache (while 'clean' removes everything in the cache, including currently available packages)...autoclean does not uninstall anything, nor does it check for any issues.)
You can also do the following:
Code:
sudo apt-get clean Which will eliminate everything downloaded and stored in the cache folder of apt. Lastly you have:
Code:
sudo apt-get autoremove which would check for any unused packages and remove them if necessary. This is great for those libraries and dependency packages that are no longer needed by any app installed.Last edited by Qqmike; Dec 07, 2020, 02:49 PM.An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski
- Top
- Bottom
Comment
-
Originally posted by kc1di View PostI know that some people don't like it but Ubuntu-cleaner will remove old kernels. I've used it many times and never had a problem with it.
you can get it from here: https://www.omgubuntu.co.uk/2016/12/...o%20BleachBit.
With Bleachbit, you have to be very careful what you do, you can quickly remove a bit too much, and make your OS unusable.Je suis Charlie, how many more people have to die for religions
linux user #447706 on https://linuxcounter.net
A good place to start: Topic: Top 20 Kubuntu FAQs & Answers
- Top
- Bottom
Comment
-
By using the apt tools that Qqmike described, you don't "need" any other tools.
I've received as many kernel updates as everyone else on this forum has, but at this moment all I have is two kernels - 5.4.0-42 and 5.4.0-48. The most I've ever had is three, right after an update. Yes, I use the apt tools.The next brick house on the left
Intel i7 11th Gen | 16GB | 1TB | KDE Plasma 5.27.11| Kubuntu 24.04 | 6.8.0-31-generic
- Top
- Bottom
Comment
Comment