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.
- Open a terminal and inspect your boot partition storage:
df -h /boot - If Use% reads 100% or has less than 50 MB of free space, you must purge obsolete kernels.
- Check your active, running kernel so you do not delete it:
uname -r - Remove old, unused kernels automatically:
sudo apt --fix-broken install && sudo apt autoremove --purge - If
aptis too broken to runautoremove, 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.
- Execute the configuration command:
sudo dpkg --configure -a - Resolve any dangling package dependencies:
sudo apt-get install -f - Update your GRUB bootloader configuration cleanly:
sudo update-grub - Run
sudo apt update && sudo apt upgradeto 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.
- Identify the specific failing package name from the terminal output (e.g.,
linux-image-generic). - Move the offending script file to a backup location:
sudo mv /var/lib/dpkg/info/linux-image-*.postinst /tmp/ - Re-run:
sudo dpkg --configure -a - Reinstall the official kernel image cleanly:
sudo apt install --reinstall linux-image-generic