The "Sub-process /usr/bin/dpkg returned an error code (1)" error occurs when the Debian package manager fails during kernel installation, typically due to corrupted package database, interrupted installation, or insufficient disk space. This can be fixed by reconfiguring dpkg, fixing broken dependencies, or freeing disk space.
This error indicates that dpkg (Debian Package manager) encountered a fatal error while processing kernel installation. The error code 1 is a generic failure code that can result from various issues: interrupted package operations, corrupted package database state, missing or conflicting files, disk space exhaustion (especially in the /boot partition which often runs out of space during kernel updates), or conflicts with third-party kernel modules. When installing a new kernel, dpkg needs to write files to the /boot partition and update the system state. If this process fails midway (due to interruption, reboot, or corruption), the package manager gets stuck in an inconsistent state. Unlike simple package installation failures, kernel installation problems are particularly critical because the system may not boot properly if the kernel installation is incomplete.
The most common and straightforward fix is to reconfigure the dpkg package database, which can repair corruption from interrupted operations:
sudo dpkg --configure -aThis command completes any pending configurations and clears the package manager's stuck state. Wait for it to complete fully before proceeding.
After reconfiguring dpkg, fix any broken dependencies that may remain:
sudo apt install -for alternatively:
sudo apt --fix-broken installThis attempts to resolve missing or conflicting packages and complete the interrupted installation.
A common cause of kernel installation failures is a full /boot partition. Check current space usage:
df -h /bootIf /boot is more than 90% full, remove old kernel versions:
sudo apt autoremove --purgeTo manually remove a specific old kernel (replace VERSION with actual version):
sudo apt remove --purge linux-image-VERSION
sudo apt remove --purge linux-headers-VERSIONClear the package cache to remove corrupted or incomplete downloaded files:
sudo apt clean
sudo apt updateThen attempt the kernel installation again:
sudo apt upgradeIf the above steps don't work, you may need to force-remove the problematic kernel package. First, identify which kernel version is causing issues by checking the error output. Then remove it:
sudo apt remove --purge linux-image-X.XX.X-XX-genericReplace the version numbers with the actual kernel version from the error message. After removal:
sudo dpkg --configure -a
sudo apt install -fVerify that you have adequate free space on your root partition (at least 500MB free recommended for kernel operations):
df -h /If disk space is critically low (less than 10% free), remove unnecessary files or applications. You can find large files with:
sudo du -sh /var/cache/*
sudo du -sh /tmp/*Then clean up cache directories:
sudo apt clean
sudo apt autoclean
sudo rm -rf /tmp/*If you have VirtualBox, Anbox, or other software that compiles kernel modules, these may fail to compile during kernel updates. As a temporary measure, uninstall them:
sudo apt remove --purge virtualbox-dkms
sudo apt remove --purge anbox-modules-dkmsThen retry the kernel installation. After the kernel is successfully installed, you can reinstall these packages if needed.
If the above steps don't resolve the issue, attempt a clean installation. First, check the dpkg log for the exact error:
tail -100 /var/log/dpkg.logIf you see a specific package name failing (e.g., linux-image-5.10.0-18), remove all related packages:
sudo apt remove --purge linux-image-5.10.0-18-generic
sudo apt remove --purge linux-headers-5.10.0-18
sudo apt remove --purge linux-headers-5.10.0-18-genericThen clean and update:
sudo apt clean
sudo apt update
sudo apt upgradeFor Raspberry Pi users and other ARM-based systems, the kernel installation process is identical, but you may encounter architecture-specific kernel versions (like linux-image-arm64). The same dpkg recovery steps apply.
If you're running Ubuntu on a server with automatic security updates enabled, the update process may fail silently without intervention. Check /var/log/apt/term.log for detailed error information.
On systems using SELinux or AppArmor, kernel module compilation errors may have additional security-related warnings. Review the full /var/log/dpkg.log to distinguish between permission issues and actual dpkg database corruption.
dpkg: serious warning: files list file for package 'package-name' contains empty filename
How to fix "files list file contains empty filename" in APT
E: Sub-process /usr/bin/dpkg returned an error code (2)
How to fix "Sub-process /usr/bin/dpkg returned an error code (2)" in APT
dpkg-divert: error: rename involves overwriting 'path' with different file
How to fix dpkg-divert rename conflicts in APT
dpkg: dependency problems prevent configuration of triggers
dpkg: dependency problems prevent configuration of triggers in apt
dpkg: unrecoverable fatal error, aborting
How to fix "dpkg: unrecoverable fatal error, aborting" in APT