0

The problem stems from running out of disk space on /boot after doing too many updates. I'm doing sudo apt update && sudo apt upgrade && sudo apt dist-upgrade and every time the linux-image updates I run sudo apt autoremove to free up space. I thought that this command removes unused linux-image-x.x.x-xx-generic from the system. Unfortunately I started running into issues with disk space when upgrading and I found this solution which works, but it's really annoying having to do this manual delete of the linux-image-x.x.x-xx-generic every time. So for example I have this command

dpkg -l | grep linux-image
rc  linux-image-5.13.0-27-generic              5.13.0-27.29~20.04.1                                 amd64        Signed kernel image generic
rc  linux-image-5.13.0-28-generic              5.13.0-28.31~20.04.1                                 amd64        Signed kernel image generic
rc  linux-image-5.13.0-30-generic              5.13.0-30.33~20.04.1                                 amd64        Signed kernel image generic
ii  linux-image-5.13.0-35-generic              5.13.0-35.40~20.04.1                                 amd64        Signed kernel image generic
ii  linux-image-5.13.0-37-generic              5.13.0-37.42~20.04.1                                 amd64        Signed kernel image generic
rc  linux-image-5.8.0-43-generic               5.8.0-43.49~20.04.1                                  amd64        Signed kernel image generic
ii  linux-image-generic-hwe-20.04              5.13.0.37.42~20.04.22                                amd64        Generic Linux kernel image

After doing

uname -r
5.13.0-35-generic

I uninstall the one's that I'm not using like in the solution I found, but this is really annoying. Is this a bug in Ubuntu or is something broken in my system?

Pachuca
  • 379
  • @Nmath Yeah, sorry it's a bit vague. It seems @vanadium understood what I was getting at anyway. I'm running out of disk space because the configuration files weren't getting deleted and my upgrades were getting blocked. I should have been using sudo apt autoremove --purge to avoid this problem. – Pachuca Mar 23 '22 at 15:59
  • @Pachuca seems like you have still misunderstood. You are seeing those lines in your output because you are NOT looking directly at a bunch of packages. You are looking at the dpkg's database output. The dpkg database of packages includes listings for packages that have been uninstalled (rc). You can --purge all you like, and those lines will still be there, still correctly showing that the packages have been removed. Whether or not config data is retained is irrelevant to your space problem -- config files are retained in /etc, not /boot. – user535733 Mar 23 '22 at 16:29

1 Answers1

3

There is no bug involved here: your old linux-image is being deleted automatically. However, its configuration data is not, and continues therefore to be listed in the output of dpkg -l, with rc at the start of the line indicating the status. See this answer for details about the output of dpkg -l.

Config files by default remain in case you reinstall the package, unless the --purge flag is used. Thus, if you want the configuration data also removed, then add that flag as

sudo apt autoremove --purge

or instead use the command

sudo apt autopurge

After the fact, i.e., if the package already is removed, you can still remove its configuration with the command:

sudo dpkg --purge linux-image-5.13.0-27-generic

To remove any residual configuration of any removed package on your system, you can use the command outlined in this answer to remove any residual configuration of packages that have been removed. It can also be done using Synaptic Package manager: list all removed packages for which residual configuration is still present by selecting the category "Not installed (residual config)".

vanadium
  • 88,010