0

Ubuntu 20.04 did a lot of kernel updates since its installation.

To keep my /boot directory clean I perform on a regular basis the following actions:

To check the space on /boot:

$ df -h

To remove APT caches and temporary files:

$ sudo apt autoremove

To display the currently active kernel:

$ uname -r

To list all the installed kernel packages an to detect old kernels:

$ dpkg -l | grep linux-image

To remove old kernel packages using the output of the previous command:

$ sudo apt remove --purge linux-image-x.xx.x-xx-generic

To clean up the dependencies of the old kernel package:

$ sudo apt autoremove --purge

The System.map-x.xx.x-xx-generic and config-x.xx.x-xx-generic files in /boot are not deleted by this procedure and are wasting a lot of place which is needed for new kernel updates

What is the procedure to remove them?

galexite
  • 576
  • 2
  • 7
albert
  • 71
  • 1
    You already mentioned the command that will clean out old kernels. It's sudo apt autoremove. What is the problem? Did you remember that you need to run sudo apt update before any other activities in apt? FYI the command to clear apt cache and temp files is sudo apt clean. autoremove removes packages that are outdated or unused dependencies. – Nmath Oct 02 '21 at 18:33
  • Is there some particular reason why you need to do this manually? A properly-working Ubuntu system will handle this automatically for you. The system failing to remove those files suggests something is wrong with your system, or that you have some unusual constraint that is yet undisclosed. – user535733 Oct 02 '21 at 20:05
  • In Ubuntu, apt by default keeps two kernels in boot, and autoremoves older ones. How many do you see? Did you change configuration in /etc/apt/apt.conf.d or /etc/kernel/postinst.d? Perhaps an apt reinstall may fix this: apt install --reinstall apt. – zwets Oct 02 '21 at 20:36
  • 4
    Does this answer your question? How do I remove old kernel versions to clean up the boot menu? , check purge-old-kernels script. – N0rbert Oct 03 '21 at 05:24

0 Answers0