How to fix dpkg: dependency problems prevent removal of linux-image-X.X.X-generic in APT

APTINTERMEDIATEHIGHUpdated Aug 7, 2026ยท 180 views

This error occurs when dpkg cannot remove a Linux kernel package due to unmet dependencies or broken package states. Fix it by repairing dependencies with apt, configuring pending packages, or manually removing old kernels to free /boot space.

Quick fix

Fixes dpkg: dependency problems prevent removal of linux-image-X.X.X-generic

uname -r
  1. Check your current kernel version
  2. Repair broken dependencies with apt
  3. Configure any pending packages
  4. List installed kernels
apt โ€” error
uname -r
dpkg: dependency problems prevent removal of linux-image-X.X.X-generic

What this error means

The dpkg package manager is refusing to uninstall a Linux kernel image package (like linux-image-5.4.0-42-generic) because other packages depend on it or the package management system is in a broken state. This typically happens during kernel upgrades when your /boot partition is full, or when DKMS modules (like wireguard) are incompatible with the kernel version you're trying to remove. The error indicates that dpkg has detected unmet dependencies that would be violated if it allowed the removal.

Typical symptoms

  • apt or dpkg commands fail when trying to remove or upgrade kernel packages
  • /boot partition shows "No space left on device" errors during updates
  • System cannot install pending kernel or driver updates
  • Automatic kernel cleanup fails during distribution upgrades
  • Multiple old kernel versions accumulate and cannot be removed
  • DKMS module compilation fails during kernel installation

Common causes

  1. /boot partition is full because multiple old kernel versions are installed and consuming space
  2. Package management system is in a broken state due to interrupted installations or upgrades
  3. DKMS modules (like wireguard, nvidia-driver) do not match the kernel version and prevent removal
  4. Another package explicitly depends on the linux-image package version you are trying to remove
  5. dpkg was interrupted during a previous operation and left packages in an unconfigured state
  6. Conflicting package versions or failed dependency resolution during updates

How to fix "dpkg: dependency problems prevent removal of linux-image-X.X.X-generic"

1Check your current kernel version

First, identify which kernel you are currently running so you do not accidentally remove it:

bash
uname -r

This outputs something like 5.15.0-86-generic. Do NOT remove this kernel as it will make your system unbootable.

2Repair broken dependencies with apt

Try the most straightforward fix first - repair any broken dependencies and configure unconfigured packages:

bash
sudo apt --fix-broken install

If that succeeds, your issue is resolved. If not, proceed to the next step.

3Configure any pending packages

If dpkg was interrupted during a previous operation, configure any unconfigured packages:

bash
sudo dpkg --configure -a

Then try the fix again:

bash
sudo apt --fix-broken install
4List installed kernels

If the above steps do not work, check which kernel versions are installed on your system:

bash
dpkg -l | grep linux-image

This shows all installed kernel packages. Identify old versions that you can safely remove (anything except your current kernel from Step 1).

5Manually remove old kernels

Once you identify an old kernel to remove, use dpkg to force-purge it:

bash
sudo dpkg --purge --force-all linux-image-5.4.0-42-generic

Replace 5.4.0-42-generic with the actual old kernel version. The --force-all flag overrides dependency checks. After removing one or two old kernels, proceed to the next step.

6Fix remaining dependency issues

After manually removing old kernels, fix any remaining broken dependencies:

bash
sudo apt-get -f install

Then update your package cache and try to complete any pending operations:

bash
sudo apt-get update
sudo apt-get upgrade
7Clean up residual package configurations

Finally, clean up any leftover package configuration files and perform automatic removal of unused packages:

bash
sudo dpkg -P $(dpkg -l | grep ^rc | awk '{print $2}')
sudo apt-get autoremove

This removes packages marked for removal and cleans up the system.

Advanced notes

For most systems, keep only 2 kernel versions installed: the currently running kernel and the immediately previous one. This provides a fallback if a kernel update breaks your system. The /boot partition is typically small (200-500MB) and runs out of space quickly with multiple kernel versions since each kernel includes compressed images, initramfs files, and DKMS modules. On systems with LVM, encrypted filesystems, or other storage constraints, managing kernel count is especially critical. If you prefer a more automated approach, use sudo apt autoremove which safely removes old kernels while keeping at least the current and previous versions. For DKMS-related failures, check if DKMS modules are compatible with your target kernel using dkms status before attempting removal.

Frequently asked questions

What does "dpkg: dependency problems prevent removal of linux-image-X.X.X-generic" mean?
0-42-generic) because other packages depend on it or the package management system is in a broken state. This typically happens during kernel upgrades when your /boot partition is full, or when DKMS modules (like wireguard) are incompatible with the kernel version you're trying to remove. The error indicates that dpkg has detected unmet dependencies that would be violated if it allowed the removal.
How do I fix "dpkg: dependency problems prevent removal of linux-image-X.X.X-generic"?
This error occurs when dpkg cannot remove a Linux kernel package due to unmet dependencies or broken package states. Fix it by repairing dependencies with apt, configuring pending packages, or manually removing old kernels to free /boot space.
What causes "dpkg: dependency problems prevent removal of linux-image-X.X.X-generic"?
/boot partition is full because multiple old kernel versions are installed and consuming space Package management system is in a broken state due to interrupted installations or upgrades DKMS modules (like wireguard, nvidia-driver) do not match the kernel version and prevent removal
Is the "dpkg: dependency problems prevent removal of linux-image-X.X.X-generic" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading