2

When I run dpkg --list 'linux-image*', the output shows that I only have 4.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? Using sudo apt-get remove ... does not do anything, because they are not currently "installed".

  • how did you install those kernels? It seems the most recent one is unknown to dpkg – Zanna Oct 10 '17 at 14:03
  • yes, all those orphaned config files can be safely deleted – ravery Oct 10 '17 at 14:03
  • I installed them using apt-get, but I think an older "cleaner" tool must have left them. – Ralph Oct 10 '17 at 14:03
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.