Ubuntu – Errors every time I use ‘apt install’ because of old kernels

aptkernelupgrade

I upgraded tot 17.04 (from Ubuntu Gnome 16.10) recently and now get the following errors every time I try apt install or apt upgrade. I have tried removing the packages that appear to raise the errors, but nothing worked so far.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages will be REMOVED:
  linux-image-extra-4.8.0-58-generic linux-image-extra-4.8.0-59-generic
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
11 not fully installed or removed.
After this operation, 322 MB disk space will be freed.
Do you want to continue? [Y/n] 
(Reading database ... 254844 files and directories currently installed.)
Removing linux-image-extra-4.8.0-58-generic (4.8.0-58.63) ...
depmod: FATAL: could not load /boot/System.map-4.8.0-58-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.8.0-58-generic /boot/vmlinuz-4.8.0-58-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.8.0-58-generic /boot/vmlinuz-4.8.0-58-generic
Error! Could not locate dkms.conf file.
File:  does not exist.
run-parts: /etc/kernel/postinst.d/dkms exited with return code 4
dpkg: error processing package linux-image-extra-4.8.0-58-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Removing linux-image-extra-4.8.0-59-generic (4.8.0-59.64) ...
depmod: FATAL: could not load /boot/System.map-4.8.0-59-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.8.0-59-generic /boot/vmlinuz-4.8.0-59-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.8.0-59-generic /boot/vmlinuz-4.8.0-59-generic
Error! Could not locate dkms.conf file.
File:  does not exist.
run-parts: /etc/kernel/postinst.d/dkms exited with return code 4
dpkg: error processing package linux-image-extra-4.8.0-59-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 linux-image-extra-4.8.0-58-generic
 linux-image-extra-4.8.0-59-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

It appears some other 17.04 packages weren't entirely installed because of this which seems to raise some other problems (such as reboots when getting out of suspend). How do I get rid of these errors/how do I get 17.04 fully working?

Edit 1:

rienheuver@rien-emperor:~$ dkms status
i915_bpo, usbc: added
i915, usbc, 4.8.0-41-generic, x86_64: installed

I have a Dell XPS 13 9350, so usbc seems relevant. But I'm not sure I use any of these and/or if they are still relevant/needed.

Best Answer

You have some crappy DKMS packages. I suggest to remove them:

sudo dkms remove i915/usbc --all
sudo dkms remove i915_bpo/usbc --all