I have tried lots of suggestions from similar posts, but without removing old kernels.

rod@rod-3000-N200:~$ sudo apt-get purge linux-image-extra-3.13.0-106-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED
  linux-image-extra-3.13.0-106-generic linux-image-extra-3.13.0-115-generic
  linux-image-extra-3.13.0-128-generic linux-image-extra-3.13.0-57-generic
0 to upgrade, 0 to newly install, 4 to remove and 25 not to upgrade.
9 not fully installed or removed.
After this operation, 454 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 651911 files and directories currently installed.)
Removing linux-image-extra-3.13.0-106-generic (3.13.0-106.153) ...
depmod: FATAL: could not load /boot/System.map-3.13.0-106-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.13.0-106-generic /boot/vmlinuz-3.13.0-106-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.13.0-106-generic /boot/vmlinuz-3.13.0-106-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-106-generic
grep: /boot/config-3.13.0-106-generic: No such file or directory
depmod: WARNING: could not open /tmp/mkinitramfs_0tkOb4/lib/modules/3.13.0-106-generic/modules.order: No such file or directory
depmod: WARNING: could not open /tmp/mkinitramfs_0tkOb4/lib/modules/3.13.0-106-generic/modules.builtin: No such file or directory

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.13.0-106-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-extra-3.13.0-106-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Removing linux-image-extra-3.13.0-115-generic (3.13.0-115.162) ...
depmod: FATAL: could not load /boot/System.map-3.13.0-115-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.13.0-115-generic /boot/vmlinuz-3.13.0-115-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.13.0-115-generic /boot/vmlinuz-3.13.0-115-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-115-generic
grep: /boot/config-3.13.0-115-generic: No such file or directory
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/usbhid/usbhid.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/usbhid/usbhid.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-apple.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-apple.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-cherry.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-cherry.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-logitech.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-logitech.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-logitech-dj.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-logitech-dj.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-microsoft.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-microsoft.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-a4tech.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-a4tech.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-belkin.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-belkin.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-chicony.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-chicony.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-cypress.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-cypress.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-ezkey.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-ezkey.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-gyration.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-gyration.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-monterey.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-monterey.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-petalynx.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-petalynx.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-pl.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-pl.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-samsung.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-samsung.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-sony.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-sony.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-sunplus.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-sunplus.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-tmff.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-tmff.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-zpff.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-zpff.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-generic.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/hid/hid-generic.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/fs/jfs/jfs.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/fs/jfs/jfs.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/fs/reiserfs/reiserfs.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/fs/reiserfs/reiserfs.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/message/i2o/i2o_block.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/message/i2o/i2o_block.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/firewire/firewire-ohci.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/firewire/firewire-ohci.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/firewire/firewire-sbp2.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/firewire/firewire-sbp2.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/firewire/firewire-ohci.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/firewire/firewire-ohci.ko not found.
cp: cannot stat ‘/lib/modules/3.13.0-115-generic/kernel/drivers/firewire/firewire-sbp2.ko’: No such file or directory
modinfo: ERROR: Module /lib/modules/3.13.0-115-generic/kernel/drivers/firewire/firewire-sbp2.ko not found.

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.13.0-115-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-extra-3.13.0-115-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Removing linux-image-extra-3.13.0-128-generic (3.13.0-128.177) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.13.0-128-generic /boot/vmlinuz-3.13.0-128-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.13.0-128-generic /boot/vmlinuz-3.13.0-128-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-128-generic

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.13.0-128-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-extra-3.13.0-128-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Removing linux-image-extra-3.13.0-57-generic (3.13.0-57.95) ...
depmod: FATAL: could not load /boot/System.map-3.13.0-57-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.13.0-57-generic /boot/vmlinuz-3.13.0-57-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.13.0-57-generic /boot/vmlinuz-3.13.0-57-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-57-generic
grep: /boot/config-3.13.0-57-generic: No such file or directory
depmod: WARNING: could not open /tmp/mkinitramfs_Q8ZMgn/lib/modules/3.13.0-57-generic/modules.order: No such file or directory
depmod: WARNING: could not open /tmp/mkinitramfs_Q8ZMgn/lib/modules/3.13.0-57-generic/modules.builtin: No such file or directory

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.13.0-57-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-extra-3.13.0-57-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
No apport report written because MaxReports has already been reached
                                                                    Errors were encountered while processing:
 linux-image-extra-3.13.0-106-generic
 linux-image-extra-3.13.0-115-generic
 linux-image-extra-3.13.0-128-generic
 linux-image-extra-3.13.0-57-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

marked as duplicate by George Udosen, karel, David Foerster, Charles Green, muru Dec 15 '17 at 6: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.

  • @user535733: I disagree. The package post-removal scripts only fail when they run out of space. The missing files don't appear to be critical or the scripts would about earlier. The problem is to somehow remove the packages without triggering out-of-space conditions which the answers to the linked question don't address either. See below. – David Foerster Dec 14 '17 at 19:01

You have a few problems, not just one.

Let's look at the very first error:

depmod: FATAL: could not load /boot/System.map-3.13.0-106-generic: No such file or directory

Don't read it like a paragraph. Read one line at a time, then stop. That's how the system wrote it.

The first line simply says that a specific file is missing. It cannot be removed because it's already gone. In the package manager's view, that's a CRITICAL ERROR worth aborting everything for...because nothing else on the system should be messing with files placed by the package manager, so you need to know that some rogue process is at work.

Historically, in the overwhelming majority of cases, that "rogue" process has turned out to be the human. This kind of problem usually crops up when the human manually deletes files to free up space in /boot.

There are three ways to handle the missing-file problem.

Recreate a dummy file: If you suspect that only one or two files were removed, use the touch command to create an empty dummy file with exactly the correct name and ownership. The package manager does not care about the content of any file - it simply needs to account for all files. This method is safe, quick, easy to undo if you make a mistake, and requires very little space in /boot.

Reinstall the entire package: For most packages outside of /boot, this is usually the correct answer. Use sudo apt install --reinstall <package_name> and apt will magically refresh all the files from the original package (stored in your local cache, newly-downloaded if not). Once apt has placed a pristine copy of all the files, apt will happily promptly remove them. This is the right way to go if you suspect that many files are missing. However, in /boot this takes up space you may not have available.

--Force dpkg to uninstall: dpkg has a set of commands to force removal of broken packages, including missing files. The command is fully explained in the manpage. Warning: dpkg --force commands are dangerous. I know a lot of people who broke their systems worse by misusing --force in the wrong situation. If you reject the first two options and decide to use --force, BACKUP YOUR DATA FIRST because you might be heading down the path to a complete reinstall. This is a method of last resort for unskilled users.

Once you fix the first error message, it's likely that any subsequent error will be also fixed or changed. So there's not much point discussing them. If there are further error message, read them. Search for key text if you don't understand. Each error message is usually a separate question.

  • By reinstall entire package do you mean System.map-3.13.0-106-generic – Backsbottom Farm Dec 20 '17 at 20:58
  • In your case, the package names arelinux-image-3.13.0-106-generic and linux-image-extra-3.13.0-106-generic – user535733 Dec 20 '17 at 22:16
  • I tried touchrod@rod-3000-N200:/boot$ touch /boot/System.map-3.13.0-106-generic touch: cannot touch ‘/boot/System.map-3.13.0-106-generic’: Permission denied – Backsbottom Farm Dec 20 '17 at 22:23
  • And why do you think permission was denied? (Hint: Who owns that folder?) – user535733 Dec 21 '17 at 0:16
  • Finally got there with sudo touch then sudo rm for unwanted config, vmline, abi and system. Then I used sudo apt install --reinstall. The sudo DPKG --purge Now Boot is around 40% full. Thanks – Backsbottom Farm Dec 21 '17 at 1:13

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