E: Sub-process /usr/bin/dpkg returned an error code (1)

Asked by Munequita

hallo,

I've been using ubuntu 16.4. Sorry I don't know how to describe exactly this issue, but every time I try to install something I receive this on Synaptic Package

E: linux-image-extra-4.4.0-21-generic: subprocess installed post-removal script returned error exit status 1
E: linux-image-4.4.0-21-generic: subprocess installed post-removal script returned error exit status 1

On terminal trying to upgrade, I think it provides more details and repeat the same thing by the end:

root@munequita:/home/munequita# apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be REMOVED:
  linux-image-4.4.0-21-generic linux-image-extra-4.4.0-21-generic
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
3 not fully installed or removed.
After this operation, 217 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 257086 files and directories currently installed.)
Removing linux-image-extra-4.4.0-21-generic (4.4.0-21.37) ...
depmod: FATAL: could not load /boot/System.map-4.4.0-21-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-21-generic /boot/vmlinuz-4.4.0-21-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-21-generic /boot/vmlinuz-4.4.0-21-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-21-generic
WARNING: missing /lib/modules/4.4.0-21-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/4.4.0-21-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_WOFeXW/lib/modules/4.4.0-21-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_WOFeXW/lib/modules/4.4.0-21-generic/modules.builtin: No such file or directory
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.0-21-generic /boot/vmlinuz-4.4.0-21-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-21-generic /boot/vmlinuz-4.4.0-21-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-21-generic /boot/vmlinuz-4.4.0-21-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-21-generic /boot/vmlinuz-4.4.0-21-generic
/usr/sbin/grub-mkconfig: 13: /etc/default/grub: GRUB_CMDLINE_LINUX_DEFAULT: not found
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-extra-4.4.0-21-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Removing linux-image-4.4.0-21-generic (4.4.0-21.37) ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.0-21-generic /boot/vmlinuz-4.4.0-21-generic
update-initramfs: Deleting /boot/initrd.img-4.4.0-21-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.4.0-21-generic /boot/vmlinuz-4.4.0-21-generic
/usr/sbin/grub-mkconfig: 13: /etc/default/grub: GRUB_CMDLINE_LINUX_DEFAULT: not found
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 127
Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-4.4.0-21-generic.postrm line 328.
dpkg: error processing package linux-image-4.4.0-21-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 linux-image-extra-4.4.0-21-generic
 linux-image-4.4.0-21-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

Please How can I fix it? I am lazy to format the computer.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Apps Directory Edit question
Assignee:
No assignee Edit question
Solved by:
Munequita
Solved:
Last query:
Last reply:
Revision history for this message
Munequita (munequitaschramm) said :
#1

hallo,

I hate computers, but anyway I've found the solution:

sudo su

rm /var/lib/dpkg/info/*

Brazilian Portuguese
https://www.youtube.com/watch?v=zdciBNGEm1Y

Thanks!

Revision history for this message
Manfred Hampl (m-hampl) said :
#2

Deleting all files in /var/lib/dpkg/info/ was not a good idea.
Correct functioning of the package management system depends on the information stored in the files in that directory.

This action probably has broken your package management system.

If you now try the commands

sudo apt-get update
sudo apt-get dist-upgrade

you will receive hundreds of error messages about missing file in that directory.

Revision history for this message
Munequita (munequitaschramm) said :
#3

No.

At least, it didn't happen to me.

As soon as I typed those commands I Updated and I didn't receive any error message. Maybe these commands are not for everyone, but you can try

sudo su

rm /var/lib/dpkg/info/*

Everything is Ok, I was unable to download and upgrade , my files, system.

Now I can update and download and finally I had a happy end.

Revision history for this message
Manfred Hampl (m-hampl) said :
#4

What is the full output of the commands

sudo apt-get update
sudo apt-get dist-upgrade

when executed in a terminal window?

For the future:
You should have followed the instructions in
https://help.ubuntu.com/community/PackageManagerTroubleshootingProcedure