0

I removed old kernels (with dpkg -P), and now many packages that I try to install complain that the miss the old (removed) kernels as dependencies

If I do a "apt-get install -f" as suggested, my old kernels get reinstalled....

sudo apt-get install synaptic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
synaptic is already the newest version (0.83).
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 linux-image-extra-4.10.0-28-generic : Depends: linux-image-4.10.0-28-generic but it is not going to be installed
 linux-image-extra-4.10.0-35-generic : Depends: linux-image-4.10.0-35-generic but it is not going to be installed
 linux-image-extra-4.10.0-37-generic : Depends: linux-image-4.10.0-37-generic but it is not going to be installed
 linux-signed-image-4.10.0-35-generic : Depends: linux-image-4.10.0-35-generic (= 4.10.0-35.39~16.04.1) but it is not going to be installed
 linux-signed-image-4.10.0-37-generic : Depends: linux-image-4.10.0-37-generic (= 4.10.0-37.41~16.04.1) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
Max L.
  • 165
  • 5
  • Your chosen method of removing the older kernels may not be the best method of removing these. You are, apparently, removing the primary bit of the kernel, but not removing the additional kernel packages - I would suggest using `sudo apt install -f` to reinstall the missing kernels, and then running `sudo apt autoremove` – Charles Green Mar 22 '18 at 14:31
  • There are two excellent kernel cleanup scripts available. [here](https://askubuntu.com/questions/892076/how-to-selectively-purge-old-kernels-all-at-once) and [here](https://launchpad.net/linux-purge). – Doug Smythies Mar 22 '18 at 15:12
  • @CharlesGreen, I cannot install the old kernels because my /boot becomes full, that puts me in a catch 22 situation ! – Max L. Mar 22 '18 at 15:24
  • Ah! - that sheds new light on the situation. As mentioned by Doug Smythies, there are a couple of very good scripts for removing old kernels. You might also review [https://askubuntu.com/questions/2793/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) and also [https://askubuntu.com/questions/89710/how-do-i-free-up-more-space-in-boot](https://askubuntu.com/questions/89710/how-do-i-free-up-more-space-in-boot) – Charles Green Mar 22 '18 at 15:31
  • I've tried various methods of removing old kernel, then when I want to add other packages, they complain about dependencies to these old (and removed) kernels – Max L. Mar 22 '18 at 15:49

1 Answers1

3

If package A (here, linux-image-extra-*** and linux-signed-image-***) depends on package B (here, linux-image-***), it is a problem if package A is installed while package B is not. There are two ways to solve this problem: install package B, or remove package A.

apt-get install -f tries to do the former, but here, it is clear that what you want to do is remove the unwanted packages, so just do it™:

sudo apt remove linux-image-extra-4.10.0-28-generic linux-image-extra-4.10.0-35-generic linux-image-extra-4.10.0-37-generic linux-signed-image-4.10.0-35-generic linux-signed-image-4.10.0-37-generic

Yes, all in one command, not separately. And in the future, please always remove package with Apt, not dpkg.

fkraiem
  • 12,344
  • 4
  • 33
  • 38