0

I have a server running Ubuntu 18.04 LTS. This morning I ran an apt upgrade and during it, the server lost power. Once it was restored, I logged in and noticed there were 2 packages "not fully installed or removed". I tried running apt-get autoremove, explicit apt-get remove commands, and numerous solutions found online that I can't remember at the moment.

Nothing seems to help, and I am unable to upgrade/install packages due to apt erring at the corrupt packages. They are kernel packages:

linux-image-4.15.0-50-generic
linux-image-4.15.0-51-generic

Here is the output of apt-get autoremove:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  linux-image-4.15.0-50-generic
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
3 not fully installed or removed.
After this operation, 8,323 kB disk space will be freed.
Do you want to continue? [Y/n]
(Reading database ... 144087 files and directories currently installed.)
Removing linux-image-4.15.0-50-generic (4.15.0-50.54) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-50-generic
/etc/kernel/postrm.d/x-grub-legacy-ec2:
Searching for GRUB installation directory ... found: /boot/grub
/etc/default/grub: line 12: net.ifnames=0: command not found
run-parts: /etc/kernel/postrm.d/x-grub-legacy-ec2 exited with return code 127
dpkg: error processing package linux-image-4.15.0-50-generic (--remove):
 installed linux-image-4.15.0-50-generic package post-removal script subprocess returned error exit status 1
Errors were encountered while processing:
 linux-image-4.15.0-50-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
  • One simple and easy-to-remember way is to reinstall the package (sudo apt install --reinstall linux-image-4.15.0-50-generic) then remove it (sudo apt remove linux-image-4.15.0-50-generic). There are more complicated ways if this fails. – user535733 Jun 16 at 16:37
  • Note that you also have a warning: 3 not fully installed or removed. Keep an eye on that. If the kernel cleanup does not bring that number down to 0, then investigate further. – user535733 Jun 16 at 16:39
  • Thanks, I was able to get the packages removed and gone. This was what I thought was causing my lighttpd install to break, but it still isn't working. I suppose I'll create a thread on their forums for further assistance. Thank you for the help! – Alex Jun 16 at 17:10
0

Running a series of apt-get autoremove and apt-get autoclean commands after manually deleting .deb files seems to have cleared it up.

  • next time you run into this you can also try this command sudo dpkg --configure -a it sometimes will clear the problem. – kc1di Jun 17 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.