Score:0

Clean up the /boot directory in 20.04

in flag

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?

Nmath avatar
ng flag
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.
user535733 avatar
cn flag
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.
zwets avatar
us flag
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`.
N0rbert avatar
zw flag
Does this answer your question? [How do I remove old kernel versions to clean up the boot menu?](https://askubuntu.com/questions/2793/how-do-i-remove-old-kernel-versions-to-clean-up-the-boot-menu) , check `purge-old-kernels` [script](https://askubuntu.com/a/623687/66509).
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.