1

I am trying to install a bunch of packages, but everytime I try to install anything I get these errors:

hira@hira-VirtualBox:~$ sudo apt-get install python-pyasn1 python-flask python-urwid python-dev libxml2-dev libxslt-dev libffi-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libxslt1-dev' instead of 'libxslt-dev'
libffi-dev is already the newest version (3.2.1-4).
libxslt1-dev is already the newest version (1.1.28-2.1).
python-dev is already the newest version (2.7.11-1).
python-flask is already the newest version (0.10.1-2build2).
python-pyasn1 is already the newest version (0.1.9-1).
python-urwid is already the newest version (1.3.1-2build1).
libxml2-dev is already the newest version (2.9.3+dfsg1-1ubuntu0.1).
The following packages were automatically installed and are no longer required:
  linux-headers-4.4.0-21 linux-headers-4.4.0-21-generic linux-image-4.4.0-21-generic
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  linux-image-extra-4.4.0-21-generic linux-image-extra-4.4.0-34-generic linux-image-extra-4.4.0-36-generic
0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
5 not fully installed or removed.
After this operation, 486 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 313730 files and directories currently installed.)
Removing linux-image-extra-4.4.0-21-generic (4.4.0-21.37) ...
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
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/vboxadd 4.4.0-21-generic /boot/vmlinuz-4.4.0-21-generic
run-parts: failed to exec /etc/kernel/postinst.d/vboxadd: Exec format error
run-parts: /etc/kernel/postinst.d/vboxadd exited with return code 1
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-extra-4.4.0-34-generic (4.4.0-34.53) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-34-generic /boot/vmlinuz-4.4.0-34-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-34-generic /boot/vmlinuz-4.4.0-34-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-34-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.0-34-generic /boot/vmlinuz-4.4.0-34-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-34-generic /boot/vmlinuz-4.4.0-34-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-34-generic /boot/vmlinuz-4.4.0-34-generic
run-parts: executing /etc/kernel/postinst.d/vboxadd 4.4.0-34-generic /boot/vmlinuz-4.4.0-34-generic
run-parts: failed to exec /etc/kernel/postinst.d/vboxadd: Exec format error
run-parts: /etc/kernel/postinst.d/vboxadd exited with return code 1
dpkg: error processing package linux-image-extra-4.4.0-34-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Removing linux-image-extra-4.4.0-36-generic (4.4.0-36.55) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-36-generic /boot/vmlinuz-4.4.0-36-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-36-generic /boot/vmlinuz-4.4.0-36-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-36-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.0-36-generic /boot/vmlinuz-4.4.0-36-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-36-generic /boot/vmlinuz-4.4.0-36-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-36-generic /boot/vmlinuz-4.4.0-36-generic
run-parts: executing /etc/kernel/postinst.d/vboxadd 4.4.0-36-generic /boot/vmlinuz-4.4.0-36-generic
run-parts: failed to exec /etc/kernel/postinst.d/vboxadd: Exec format error
run-parts: /etc/kernel/postinst.d/vboxadd exited with return code 1
dpkg: error processing package linux-image-extra-4.4.0-36-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-extra-4.4.0-34-generic
 linux-image-extra-4.4.0-36-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

I have tried to remove old kernels using this guide but thats not helping either. I am getting these errors: enter image description here

sudo apt-get -f install also results in the same exact error. And sudo dpkg --configure -a returns nothing.

Also, these are my currently installed kernels:

ls -l /boot | grep vmlinuz
-rw-r--r-- 1 root root  7013984 اگست   3 11:12 vmlinuz-4.4.0-21-generic
-rw------- 1 root root  7046160 جولاي 28 02:28 vmlinuz-4.4.0-34-generic
-rw------- 1 root root  7045472 اگست  12 00:58 vmlinuz-4.4.0-36-generic

I have also followed the advice over here, to try to reinstall and then remove the non-active kernels but thats giving the same error:

sudo apt-get install --reinstall linux-image-4.4.0-21-generic linux-headers-4.4.0-21-generic linux-image-extra-4.4.0-21-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-image-extra-4.4.0-34-generic linux-image-extra-4.4.0-36-generic
0 upgraded, 0 newly installed, 3 reinstalled, 2 to remove and 0 not upgraded.
5 not fully installed or removed.
Need to get 0 B/58.3 MB of archives.
After this operation, 325 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 313730 files and directories currently installed.)
Removing linux-image-extra-4.4.0-34-generic (4.4.0-34.53) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-34-generic /boot/vmlinuz-4.4.0-34-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-34-generic /boot/vmlinuz-4.4.0-34-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-34-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.0-34-generic /boot/vmlinuz-4.4.0-34-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-34-generic /boot/vmlinuz-4.4.0-34-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-34-generic /boot/vmlinuz-4.4.0-34-generic
run-parts: executing /etc/kernel/postinst.d/vboxadd 4.4.0-34-generic /boot/vmlinuz-4.4.0-34-generic
run-parts: failed to exec /etc/kernel/postinst.d/vboxadd: Exec format error
run-parts: /etc/kernel/postinst.d/vboxadd exited with return code 1
dpkg: error processing package linux-image-extra-4.4.0-34-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Removing linux-image-extra-4.4.0-36-generic (4.4.0-36.55) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-36-generic /boot/vmlinuz-4.4.0-36-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-36-generic /boot/vmlinuz-4.4.0-36-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-36-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.0-36-generic /boot/vmlinuz-4.4.0-36-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-36-generic /boot/vmlinuz-4.4.0-36-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-36-generic /boot/vmlinuz-4.4.0-36-generic
run-parts: executing /etc/kernel/postinst.d/vboxadd 4.4.0-36-generic /boot/vmlinuz-4.4.0-36-generic
run-parts: failed to exec /etc/kernel/postinst.d/vboxadd: Exec format error
run-parts: /etc/kernel/postinst.d/vboxadd exited with return code 1
dpkg: error processing package linux-image-extra-4.4.0-36-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 linux-image-extra-4.4.0-34-generic
 linux-image-extra-4.4.0-36-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

Could anyone please help what could be going wrong? I am running Ubuntu 16.04 on Virtualbox. And am quite new to Ubuntu. Thanks.

marked as duplicate by David Foerster, user.dz, Zanna, Eric Carvalho, Jens Erat Nov 17 '16 at 22:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.