Can I remove old kernels from /boot
You can safely remove unused kernels from /boot.
Ideally you want to use your package manager (apt) for removal, so you may want to see if you can remove them using:
sudo apt-get purge linux-image-4.2.0-16-generic
or if apt won't work:
sudo dpkg --purge linux-image-4.2.0-16-generic
adding to, or repeating the above for the kernels (4.2.0-16, 4.2.0-42, etc.) you would like to remove.
If the above doesn't work you can remove them manually:
sudo rm /boot/abi-4.2.0-16-generic
sudo rm /boot/config-4.2.0-16-generic
sudo rm /boot/initrd.img-4.2.0-16-generic
sudo rm /boot/System.map-4.2.0-16-generic
sudo rm /boot/vmlinuz-4.2.0-16-generic
or if you like to live dangerously, something like:
sudo rm /boot/*-4.2.0-16-generic
An additional kernel (to the one you're running) is sometimes left as a backup, so you may want to do so in case of issues with the currently running kernel.
After removing these files you should update your boot loader, if you are using GRUB you would do the following:
sudo update-grub
I would also consider whether a "Cleaner" tool that removed packages from apt without removing the files is doing you any good.
EDIT:
As pointed out by WinEunuuchs2Unix, this does not remove the header files. Normally when removing old kernels you would remove not just the image, but the other associated files as well. For example:
apt-get purge linux-image-4.2.0-16-generic linux-image-extra-4.2.0-16-generic linux-headers-4.2.0-16-generic linux-headers-4.2.0-16
See link below for more details.
Ralph
Physician, retired. Retired software engineer/developer (Master of Science in Computer Science). I currently program mostly in Go. I am particularly interested in functional programming. In past lives, I programmed in Java, Scala, Basic, Fortran, Pascal, Forth, C (extensively, at Bell Labs), C++, Groovy, and various assembly languages. Started programming in assembly language in 1976. I started a martial arts school in 1986 (Shojin Cuong Nhu in New Jersey) and currently teach at the Tallest Tree Dojo in Gainesville, Florida. I like to cook. I am an atheist. Email: user: grk, host: usa.net
Updated on September 18, 2022Comments
-
Ralph over 1 year
When I run
dpkg --list 'linux-image*'
, the output shows that I only have4.10.0-37
installed:Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-=========================-=================-=================-======================================================= un linux-image <none> <none> (no description available) ii linux-image-4.10.0-37-gen 4.10.0-37.41 amd64 Linux kernel image for version 4.10.0 on 64 bit x86 SMP ii linux-image-extra-4.10.0- 4.10.0-37.41 amd64 Linux kernel extra modules for version 4.10.0 on 64 bit ii linux-image-generic 4.10.0.37.37 amd64 Generic Linux kernel image
however, when I show the contents of
/boot
, there are other old kernels:[~]$ ls /boot abi-4.10.0-37-generic config-4.8.0-37-generic memtest86+.bin vmlinuz-4.10.0-37-generic abi-4.2.0-16-generic efi memtest86+.elf vmlinuz-4.10.0-37-generic.efi.signed abi-4.2.0-42-generic grub memtest86+_multiboot.bin vmlinuz-4.2.0-16-generic abi-4.8.0-37-generic initrd.img-4.10.0-37-generic System.map-4.10.0-37-generic vmlinuz-4.2.0-42-generic config-4.10.0-37-generic initrd.img-4.2.0-16-generic System.map-4.2.0-16-generic vmlinuz-4.2.0-42-generic.efi.signed config-4.2.0-16-generic initrd.img-4.2.0-42-generic System.map-4.2.0-42-generic vmlinuz-4.8.0-37-generic config-4.2.0-42-generic initrd.img-4.8.0-37-generic System.map-4.8.0-37-generic vmlinuz-4.8.0-37-generic.efi.signed
I am running
4.10.0-37
:[~]$ uname -r 4.10.0-37-generic
Can I safely delete the old kernels () from
/boot
? Usingsudo apt-get remove ...
does not do anything, because they are not currently "installed".-
Zanna over 6 yearshow did you install those kernels? It seems the most recent one is unknown to dpkg
-
ravery over 6 yearsyes, all those orphaned config files can be safely deleted
-
Ralph over 6 yearsI installed them using
apt-get
, but I think an older "cleaner" tool must have left them.
-
-
WinEunuuchs2Unix over 6 yearsThis doesn't remove header files. Try
rm-kernels
. See: askubuntu.com/questions/892076/…