From everything I've read, in Ubuntu 18.04 sudo apt-get autoremove
should clean up old kernels. However, for some reason, after installing a new kernel version, I am left with "linux-image-*", "linux-headers-*" and "linux-modules-*" packages which are inexplicably marked as manually installed, and therefore are not cleaned up by apt-get autoremove
.
I have not manually installed these packages (for example linux-image-4.15.0-70-generic
), and can't figure out what is marking them as manually installed.
Why are these packages getting marked as manually installed? And how can I stop that from happening?
I'm replying to @user535733 here, because it is too long for a comment. I think this is something different than the script in /etc/kernel/postinst.d/apt-auto-removal.
Looking at that script, it doesn't mark the packages as manually installed, instead it writes an apt configuration file with a "APT::NeverAutoRemove" section that lists the kernels that shouldn't be removed. And I understand that. The problem is the packages I'm seeing marked as manually installed are not in that list. And they are never removed by autoremove
even after multiple kernel updates.
And by marked as manually installed, I mean that apt-mark showmanual linux-*
lists these packages and apt-mark showauto linux-*
does not.
I found this in my apt history:
Remove: linux-headers-5.0.0-32:amd64 (5.0.0-32.34~18.04.2), linux-modules-extra-5.0.0-32-generic:amd64 (5.0.0-32.34~18.04.2), linux-headers-5.0.0-32-generic:amd64 (5.0.0-32.34~18.04.2), linux-image-4.15.0-70-generic:amd64 (4.15.0-70.79), linux-modules-5.0.0-32-generic:amd64 (5.0.0-32.34~18.04.2), linux-modules-extra-4.15.0-70-generic:amd64 (4.15.0-70.79), linux-image-5.0.0-32-generic:amd64 (5.0.0-32.34~18.04.2), gradle-6.0:amd64 (1.0-0ubuntu2), linux-modules-4.15.0-70-generic:amd64 (4.15.0-70.79)
Error: Sub-process /usr/bin/dpkg returned an error code (2)
And the corresponding term.log contains:
Log started: 2019-12-21 22:23:02
dpkg: warning: 'ldconfig' not found in PATH or not executable
dpkg: warning: 'start-stop-daemon' not found in PATH or not executable
dpkg: error: 2 expected programs not found in PATH or not executable
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin
Log ended: 2019-12-21 22:23:02
So it looks like autoremove tried and failed to remove the packages. (And I think it is failing because it is in a cron job and the PATH isn't set correctly). I still don't understand how they became marked as manually installed though. I don't see anything else suspicious in the apt history or term.log
No comments:
Post a Comment