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?
sudo apt autoremove. What is the problem? Did you remember that you need to runsudo apt updatebefore any other activities inapt? FYI the command to clear apt cache and temp files issudo apt clean.autoremoveremoves packages that are outdated or unused dependencies. – Nmath Oct 02 '21 at 18:33aptby default keeps two kernels in boot, and autoremoves older ones. How many do you see? Did you change configuration in/etc/apt/apt.conf.dor/etc/kernel/postinst.d? Perhaps an apt reinstall may fix this:apt install --reinstall apt. – zwets Oct 02 '21 at 20:36purge-old-kernelsscript. – N0rbert Oct 03 '21 at 05:24