How to Fix ‘Sub-process /usr/bin/dpkg Returned an Error Code (1)’ During Kernel Updates in Ubuntu

Updating package repositories via sudo apt upgrade on Ubuntu should conclude with clean configuration triggers. However, when the installation halts abruptly during kernel processing with an error reading ‘dpkg: error processing package linux-image-… (–configure): installed linux-image-… post-installation script subprocess returned error exit status 1. Sub-process /usr/bin/dpkg returned an error code (1)’, package management becomes blocked.

This critical package failure almost always stems from a completely saturated /boot partition unable to house new initramfs ramdisk images, broken DKMS kernel module builds, or orphaned package metadata scripts inside /var/lib/dpkg/info/. Following this procedure will safely unblock dpkg.

Check and Free Exhausted /boot Partition Space

In standard Ubuntu installations, the /boot directory resides on a dedicated partition (often limited to 500 MB to 1 GB). When several legacy kernels accumulate, insufficient space remains to compile new initramfs files, causing dpkg to fail with exit code 1.

  1. Open a terminal and inspect your boot partition storage:
    df -h /boot
  2. If Use% reads 100% or has less than 50 MB of free space, you must purge obsolete kernels.
  3. Check your active, running kernel so you do not delete it:
    uname -r
  4. Remove old, unused kernels automatically:
    sudo apt --fix-broken install && sudo apt autoremove --purge
  5. If apt is too broken to run autoremove, manually remove unneeded legacy kernel images (ensure you NEVER delete the active kernel identified in step 3):
    sudo rm -f /boot/*-old-kernel-version*

Force Reconfiguration of Unfinished Packages

Once disk capacity on /boot is restored, force dpkg to re-evaluate and configure all pending packages.

  1. Execute the configuration command:
    sudo dpkg --configure -a
  2. Resolve any dangling package dependencies:
    sudo apt-get install -f
  3. Update your GRUB bootloader configuration cleanly:
    sudo update-grub
  4. Run sudo apt update && sudo apt upgrade to verify that all packages finish without errors.

Move Damaged Post-Installation Scripts Aside

If an individual kernel package maintains an unresolvable bash syntax error inside its custom post-install script, temporarily moving the script allows dpkg to finalise setup.

  1. Identify the specific failing package name from the terminal output (e.g., linux-image-generic).
  2. Move the offending script file to a backup location:
    sudo mv /var/lib/dpkg/info/linux-image-*.postinst /tmp/
  3. Re-run:
    sudo dpkg --configure -a
  4. Reinstall the official kernel image cleanly:
    sudo apt install --reinstall linux-image-generic

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.