Autoremoval of old kernels leaves linux-tools and linux-headers packages

Asked by Sebastian Geiger

I just noticed that I had as many as 17 old kernels installed on my system, but apt-get's autoremove funktion would not delete them.
Using this answer http://askubuntu.com/questions/620266/how-does-apt-decide-how-many-old-kernels-to-keep I used apt-mark to mark most of them for autoremoval:

sudo apt-mark auto ^linux-image-

Then I used apt-get autoremove which removed all but the latest three kernels.

Now I just noticed that there are still a lot of linux-tools and linux-header packages installed. My first question would be if there is some bug at work that causes them to be left over, and the second question is how can I easily remove them from the system. Or is there a reason these packages have been left on the system?

Question information

Language:
English Edit question
Status:
Expired
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said :
#1

For diagnostic purposes please provide the output of he following commands

uname -a
lsb_release -crid
dpkg -l | grep ' linux-'
apt-mark showmanual | grep ^linux-

Revision history for this message
Sebastian Geiger (lanoxx) said :
#2

$ uname -a
Linux earth 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -crid
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial

$apt-mark showmanual | grep ^linux-
linux-firmware
linux-generic
linux-headers-generic
linux-libc-dev
linux-sound-base
linux-tools
linux-tools-common
linux-tools-generic

$ dpkg -l | grep ' linux-' see:
https://paste.ubuntu.com/23972686/

Revision history for this message
Manfred Hampl (m-hampl) said :
#3

It seems that you need help in correctly interpreting the status information of packages on your system.

If you look at the first column in the output on https://paste.ubuntu.com/23972686/ you can see different status values, namely ii and rc.

ii means "should be installed" and "is installed"
rc means "should be removed" and "is removed and just the config file is left"

The background is as follows:
Some of the packages store information about the configuration that was selected when the package was installed in a separate file. This allows using the same settings as before, If you uninstall that package and install it again. If you no not plan to re-use these settings any more, because you uninstall the package without intent to reinstall it, then it makes sense to delete also the configuration information.

There are different commands or options to keep and to remove the configuration information when uninstalling a package.

"sudo apt-get remove package" uninstalls the package, but leave the config information in place
"sudo apt-get purge package" uninstalls the package and deletes the config information
"sudo apt-get remove --purge package" also uninstalls the package and deleted the config info

similarly
"sudo apt-get autoremove" uninstalls obsolete packages, but keeps their config info in place
"sudo apt-get --purge autoremove" uninstalls obsolete packages and deletes the confog info.

The command
dpkg --list |grep "^rc" | cut -d " " -f 3 | xargs sudo dpkg --purge
deletes all residual config files from packages that have already been uninstalled.

Revision history for this message
Sebastian Geiger (lanoxx) said :
#4

I should have mentioned that after asking that question I manually uninstalled all the linux-headers and linux-tools packages that I did not need anymore, so the above output only shows the current state but not how it was when I asked the question. So when I asked the question there were actually about 10 linux-headers and 10 linux-tools package installed (with an i in the front).

From the commands you posted I think I know most of them, except that it was interesting to learn that I can combine --purge and autoremove, I shall use that one more often in the future.

I would still be interested to know if Ubuntu under normal circumstances is supposed to automatically clean up linux-headers packages and linux-tools packages.

Revision history for this message
Launchpad Janitor (janitor) said :
#5

This question was expired because it remained in the 'Open' state without activity for the last 15 days.