8

Firstly, I've looked at the various other questions and answers on this topic and they've not fixed my problem, so I've not just dashed in without a long stint on Google and here. Also, there's no separate boot partition and there's plenty of space available.

I'm on 16.04 and I think what happened was that my laptop got rebooted or crashed while running an update. Certainly it was unexpectedly off when I came back to it and now I can not install anything with apt-get. In my pursuit of a solution the only major change from where it was at that point is that I tried forcing the removal of linux-generic as suggested somewhere but although that succeeded in removing the package it would not reinstall.

Currently I've been able to fall back to kernel 4.8.0-54-generic which is working reasonably well (I'm using the laptop now).

I'll start with dpkg --audit:

The following packages have been unpacked but not yet configured.
They must be configured using dpkg --configure or the configure
menu option in dselect for them to work:
 linux-generic-hwe-16.04 Complete Generic Linux kernel and headers
 linux-image-extra-4.8.0-56-generic Linux kernel extra modules for version 4.8.
 linux-image-extra-4.8.0-58-generic Linux kernel extra modules for version 4.8.
 linux-image-generic-hwe-16.04 Generic Linux kernel image

The following packages are only half configured, probably due to problems
configuring them the first time. The configuration should be retried using
dpkg --configure <package> or the configure menu option in dselect:
 linux-image-4.8.0-53-generic Linux kernel image for version 4.8.0 on 64 bit x8
 linux-image-4.8.0-56-generic Linux kernel image for version 4.8.0 on 64 bit x8
 linux-image-4.8.0-58-generic Linux kernel image for version 4.8.0 on 64 bit x8

The following packages are only half installed, due to problems during
installation. The installation can probably be completed by retrying it;
the packages can be removed using dselect or dpkg --remove:
 linux-image-extra-4.4.0-83-generic Linux kernel extra modules for version 4.4.
 linux-image-extra-4.8.0-53-generic Linux kernel extra modules for version 4.8.

Running for i in /boot/vmlinuz* ; do dpkg -S $i | egrep -v $(uname -r); done |cut -d- -f3-4 outputs:

4.4.0-53
4.8.0-53
4.8.0-56
4.8.0-58

dpkg basically won't do anything except some deletions. So dpkg --configure -a produces:

Setting up linux-image-4.8.0-53-generic (4.8.0-53.56~16.04.1) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Not updating initrd symbolic links since we are being updated/reinstalled 
(4.8.0-53.56~16.04.1 was configured last, according to dpkg)
Not updating image symbolic links since we are being updated/reinstalled 
(4.8.0-53.56~16.04.1 was configured last, according to dpkg)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.8.0-53-generic /boot/vmlinuz-4.8.0-53-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.8.0-53-generic /boot/vmlinuz-4.8.0-53-generic
Error! Your kernel headers for kernel 4.8.0-53-generic cannot be found.
Please install the linux-headers-4.8.0-53-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.8.0-53-generic /boot/vmlinuz-4.8.0-53-generic
update-initramfs: Generating /boot/initrd.img-4.8.0-53-generic
cp: cannot stat '/etc/fonts/conf.d/60-latin.conf': No such file or directory
E: /usr/share/initramfs-tools/hooks/plymouth failed with return 1.
update-initramfs: failed for /boot/initrd.img-4.8.0-53-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-4.8.0-53-generic.postinst line 1052.
dpkg: error processing package linux-image-4.8.0-53-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
Setting up linux-image-4.8.0-58-generic (4.8.0-58.63~16.04.1) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
The link /initrd.img is a dangling linkto /boot/initrd.img-4.8.0-56-generic
Examining /etc/kernel/postinst.d.
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
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.8.0-58-generic /boot/vmlinuz-4.8.0-58-generic
update-initramfs: Generating /boot/initrd.img-4.8.0-58-generic
W: Possible missing firmware /lib/firmware/i915/kbl_dmc_ver1_01.bin for module i915
cp: cannot stat '/etc/fonts/conf.d/60-latin.conf': No such file or directory
E: /usr/share/initramfs-tools/hooks/plymouth failed with return 1.
update-initramfs: failed for /boot/initrd.img-4.8.0-58-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-4.8.0-58-generic.postinst line 1052.
dpkg: error processing package linux-image-4.8.0-58-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
Setting up linux-image-4.8.0-56-generic (4.8.0-56.61~16.04.1) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
The link /initrd.img is a dangling linkto /boot/initrd.img-4.8.0-58-generic
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.8.0-56-generic /boot/vmlinuz-4.8.0-56-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.8.0-56-generic /boot/vmlinuz-4.8.0-56-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.8.0-56-generic /boot/vmlinuz-4.8.0-56-generic
update-initramfs: Generating /boot/initrd.img-4.8.0-56-generic
W: Possible missing firmware /lib/firmware/i915/kbl_dmc_ver1_01.bin for module i915
cp: cannot stat '/etc/fonts/conf.d/60-latin.conf': No such file or directory
E: /usr/share/initramfs-tools/hooks/plymouth failed with return 1.
update-initramfs: failed for /boot/initrd.img-4.8.0-56-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-4.8.0-56-generic.postinst line 1052.
dpkg: error processing package linux-image-4.8.0-56-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of linux-image-generic-hwe-16.04:
 linux-image-generic-hwe-16.04 depends on linux-image-4.8.0-58-generic; however:
  Package linux-image-4.8.0-58-generic is not configured yet.

dpkg: error processing package linux-image-generic-hwe-16.04 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-image-extra-4.8.0-58-generic:
 linux-image-extra-4.8.0-58-generic depends on linux-image-4.8.0-58-generic; however:
  Package linux-image-4.8.0-58-generic is not configured yet.

dpkg: error processing package linux-image-extra-4.8.0-58-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-image-extra-4.8.0-56-generic:
 linux-image-extra-4.8.0-56-generic depends on linux-image-4.8.0-56-generic; however:
  Package linux-image-4.8.0-56-generic is not configured yet.

dpkg: error processing package linux-image-extra-4.8.0-56-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic-hwe-16.04:
 linux-generic-hwe-16.04 depends on linux-image-generic-hwe-16.04 (= 4.8.0.58.29); however:
  Package linux-image-generic-hwe-16.04 is not configured yet.

dpkg: error processing package linux-generic-hwe-16.04 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 linux-image-4.8.0-53-generic
 linux-image-4.8.0-58-generic
 linux-image-4.8.0-56-generic
 linux-image-generic-hwe-16.04
 linux-image-extra-4.8.0-58-generic
 linux-image-extra-4.8.0-56-generic
 linux-generic-hwe-16.04

Notice that it complains about missing header files for a different kernel from the one actually running (-53 instead of -54, both of which are quite far behind the highest kernel I had installed before this mess erupted).

apt-get -f install gives:

 Reading package lists... Done
 Building dependency tree       
 Reading state information... Done
 Correcting dependencies... Done
 The following packages were automatically installed and are no longer required:
   linux-headers-4.4.0-83 linux-headers-4.4.0-83-generic linux-image-4.4.0-83-generic linux-image-extra-4.4.0-83-generic
 Use 'sudo apt autoremove' to remove them.
 The following additional packages will be installed:
   libcogl-common libcogl-pango20 linux-image-4.4.0-83-generic
 Suggested packages:
   fdutils linux-doc-4.4.0 | linux-source-4.4.0 linux-tools
 The following packages will be REMOVED
   linux-image-extra-4.8.0-53-generic
 The following NEW packages will be installed
   libcogl-common libcogl-pango20 linux-image-4.4.0-83-generic
 0 to upgrade, 3 to newly install, 1 to remove and 78 not to upgrade.
 9 not fully installed or removed.
 Need to get 0 B/58.0 MB of archives.
 After this operation, 94.3 MB disk space will be freed.
 Do you want to continue? [Y/n] y
 (Reading database ... 389562 files and directories currently installed.)
 Removing linux-image-extra-4.8.0-53-generic (4.8.0-53.56~16.04.1) ...
 run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.8.0-53-generic /boot/vmlinuz-4.8.0-53-generic
 run-parts: executing /etc/kernel/postinst.d/dkms 4.8.0-53-generic /boot/vmlinuz-4.8.0-53-generic
 Error! Your kernel headers for kernel 4.8.0-53-generic cannot be found.
 Please install the linux-headers-4.8.0-53-generic package,
 or use the --kernelsourcedir option to tell DKMS where it's located
 run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.8.0-53-generic /boot/vmlinuz-4.8.0-53-generic
 update-initramfs: Generating /boot/initrd.img-4.8.0-53-generic
 cp: cannot stat '/etc/fonts/conf.d/60-latin.conf': No such file or directory
 E: /usr/share/initramfs-tools/hooks/plymouth failed with return 1.
 update-initramfs: failed for /boot/initrd.img-4.8.0-53-generic with 1.
 run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
 dpkg: error processing package linux-image-extra-4.8.0-53-generic (--remove):
  subprocess installed post-removal script returned error exit status 1
 Errors were encountered while processing:
  linux-image-extra-4.8.0-53-generic
 E: Sub-process /usr/bin/dpkg returned an error code (1)

Finally, apt-get upgrade gives:

 Reading package lists... Done
 Building dependency tree       
 Reading state information... Done
 You might want to run ‘apt-get -f install’ to correct these.
 The following packages have unmet dependencies.
  libclutter-1.0-0 : Depends: libcogl-pango20 (>= 1.17.4) but it is not installed
                     Recommends: libclutter-1.0-common but it is not installed
  linux-image-extra-4.4.0-83-generic : Depends: linux-image-4.4.0-83-generic but it is not installed
 E: Unmet dependencies. Try using -f.

And that's where I am. There doesn't seem to be a lot wrong - just a few kernel packages screwed up but I'm having a bad time trying to resolve it. I'd rather not have to reinstall as there are databases on this machine which would be lost and I don't have space to back up at the moment. They're not critical but it would take a day or two rebuild them and at the moment the machine is actually working well, except for the fact that it can't be updated.

What do I try next?

BobLong
  • 81
  • Please try sudo apt update then sudo apt dist-upgrade – George Udosen Jul 10 '17 at 10:06
  • @George the update runs but the dist-upgrade gives the same result as the apt-get upgrade line given in the post. – BobLong Jul 10 '17 at 10:21
  • ok, try sudo apt update then sudo apt install -f – George Udosen Jul 10 '17 at 10:22
  • @George Yep, same as the output from apt-get -f install shown above - the one that bizarrely complains about the missing font.conf – BobLong Jul 10 '17 at 11:20
  • Did you try installing the package headers to satisfy dkms? – user535733 Jul 10 '17 at 12:01
  • @user535733 I'm not quite sure what you mean about package "headers" but every attempt to install anything has ended with the same failure message as the install -f command. This includes attempts to install the unmet dependencies listed in the errors. – BobLong Jul 10 '17 at 12:58
  • @user535733 Oh, right! Yes I did but I got the same problem as any other install attempt. – BobLong Jul 10 '17 at 13:16
  • It looks lik3 you got interrupted after download, so possibly the headers were downloaded but not yet installed. Try sudo dpkg -i /var/cache/apt/archives/linux-headers-4.8.0-53-generic.deb - if this does not work, you will need to download the header files from ubuntu packages – Charles Green Jul 10 '17 at 14:01
  • @CharlesGreen Thanks. The dpkg command fails as usual so I'll try a manual download when I get home tonight.

    Thanks, everyone, for your help so far.

    – BobLong Jul 10 '17 at 14:07
  • If the dpkg install fails for the same error, downloading the deb will not help with the problem. There may be a solution be forcing removal of some of the unconfigured linux kernels, but that is beyond my experience. – Charles Green Jul 10 '17 at 14:15
  • @CharlesGreen I can probably source a raw set of headers and plonk them where it expects to see them and use the --kernelsourcedir option. How hard can it be? :) – BobLong Jul 10 '17 at 14:36
  • It seems unlikely that installing the linux-headers-4.8.0-53-generic will fail due to that package being not-installed. That's exactly what package managers avoid failing at. Is there, perhaps, more to the problem that is not in your question yet? – user535733 Jul 10 '17 at 17:05
  • @user535733 Well, after thinking about it it occurred to me that I don't know why the system cares about headers for 4.8.0-53 since I'm actually running -54. Indeed I'd ideally like to remove all the other kernels and get to a clean state. Any idea why it's picking -53? – BobLong Jul 11 '17 at 06:53
  • Since you have dkms installed, apt will try to install headers for all kernel images installed, regardless of which one you happen to be running today. So, sure, another option to fix the problem is to uninstall the -53 kernel image. – user535733 Jul 11 '17 at 16:02
  • I see, in your account of compilation that you are advised as follows [The following packages were automatically installed and are no longer required: linux-headers-4.4.0-83 linux-headers-4.4.0-83-generic linux-image-4.4.0-83-generic linux-image-extra-4.4.0-83-generic Use 'sudo apt autoremove' to remove them.] Did you take this advise ? – Duchamp Gérard H. E. Mar 21 '20 at 03:19

1 Answers1

1

I actually faced problem that same with you. And I think, I just fix it. See screenshot here

First, download and install linux-headers-4.8.0-53_4.8.0-53.56~16.04.1_all.deb.

Then, download and install linux-headers-4.8.0-53-generic_4.8.0-53.56~16.04.1_amd64.deb.

Try apt update then apt upgrade.

UPDATE

If you find error like E: Sub-process /usr/bin/dpkg returned an error code (1), just follow these step.

  1. Run dpkg --remove --force-remove-reinstreq linux-image-extra-4.8.0-58-generic
  2. Then run apt install linux-image-extra-4.8.0-58-generic