How to fix dpkg: error processing archive: failed to write to copy of file: No space left on device in APT

APTINTERMEDIATEHIGHUpdated Dec 29, 2025· 209 views

This dpkg error occurs when your system runs out of disk space during package installation or updates. The /boot partition is often the culprit, filled with old kernel images. Free up space by removing outdated kernels and clearing cache files.

Quick fix

Fixes dpkg: error processing archive: failed to write to copy of file: No space left on device

df -h
  1. Check available disk space and identify the problem partition
  2. Check your current kernel version to avoid removing it
  3. Remove old kernel images to free space
  4. Clear package cache to free additional space
apt — error
df -h
dpkg: error processing archive: failed to write to copy of file: No space left on device

What this error means

This error happens when the dpkg package manager tries to write extracted package files to disk but fails because there's no available space. On Debian-based systems like Ubuntu, the /boot partition is frequently the bottleneck—it accumulates old Linux kernel versions over time and can fill up completely. When dpkg attempts to write files (like new kernels), the operation fails, leaving the system in a broken state with incomplete package installations. The "No space left on device" condition is absolute: the filesystem must have free inodes and free blocks. dpkg operations are sensitive to this because they involve writing large files like kernel images (often 50-200 MB each) and updating system-critical files.

Typical symptoms

  • apt update, apt upgrade, or apt install commands fail with the dpkg error message
  • Package manager shows 'E: Could not perform immediate configuration on package' or similar errors
  • Running df -h shows the /boot partition at 100% usage (0 bytes available)
  • System cannot install security updates or any new packages
  • Previous partial installations leave broken dependencies
  • apt autoremove fails because there's no space to complete the operation

Common causes

  1. Too many old kernel images in /boot partition—each kernel can consume 50-200 MB of space. Linux distributions don't automatically clean these up during updates.
  2. The /boot partition is too small—many systems have only 500 MB to 1 GB allocated, which fills up after just 3-5 kernel updates.
  3. Large log files or package cache in /var/cache/apt accumulating over time without cleanup.
  4. Container images or system snapshots taking up space in root filesystem when /boot is on the same partition.
  5. VM or cloud instance with insufficient disk space allocated during initial setup.

How to fix "dpkg: error processing archive: failed to write to copy of file: No space left on device"

1Check available disk space and identify the problem partition

Run this command to see all partitions and their usage:

bash
df -h

Look for any partition at 100% usage. Pay special attention to /boot. If /boot shows 100%, you've found the culprit. Run this to see what's consuming space:

bash
du -sh /boot/*

This will show large files (usually old kernels) taking up space.

2Check your current kernel version to avoid removing it

Before removing kernels, identify which one is currently running:

bash
uname -r

This outputs something like 5.15.0-84-generic. Make a note of this—DO NOT remove this kernel. List all installed kernels:

bash
dpkg -l 'linux-*' | grep '^ii'

You'll see multiple kernel versions. Identify the older ones that differ from your current kernel.

3Remove old kernel images to free space

Replace 5.15.0-83-generic with the actual old kernel version from the previous step (one that's NOT your current kernel):

bash
sudo apt-get remove --purge linux-image-5.15.0-83-generic
sudo apt-get remove --purge linux-headers-5.15.0-83-generic

Or use autoremove to remove all unused kernels at once (safe, only removes unused ones):

bash
sudo apt-get autoremove --purge

If you get "No space left on device" even with autoremove, try removing the oldest kernel manually first to create space, then use autoremove.

4Clear package cache to free additional space

Once you've freed some space, clean up the apt cache:

bash
sudo apt clean
sudo apt autoclean

apt clean removes all cached .deb files. apt autoclean removes only old cached packages. This can free up several hundred MB.

5Fix any broken packages and complete the installation

After freeing space, fix any incomplete package operations:

bash
sudo apt-get -f install

This repairs dependencies and completes any interrupted installations. Then try your original command again:

bash
sudo apt update
sudo apt upgrade

Advanced notes

On systems with separate /boot partitions: The /boot partition is critical for system boot and should have at least 100-200 MB free at all times. If you find yourself constantly removing kernels, consider expanding /boot during the next maintenance window using tools like LVM (Logical Volume Manager) or by repartitioning.

On cloud VMs and Docker containers: If you're running on a cloud instance (AWS, DigitalOcean, Linode, etc.), the root filesystem size was set during initial provisioning. After freeing space, monitor disk usage with tools like ncdu for long-term capacity planning.

Alternative approach using update-initramfs: Some users remove only the initramfs files instead of full kernel packages: sudo update-initramfs -d -k 5.15.0-83-generic (replace with old kernel version). This is more conservative but frees less space.

Distribution-specific notes: Ubuntu normally handles kernel cleanup automatically if you use the "linux-image-generic" meta-package (which depends on the latest kernel). However, if you manually installed specific kernel versions, you must manage cleanup yourself.

Frequently asked questions

What does "dpkg: error processing archive: failed to write to copy of file: No sp" mean?
This error happens when the dpkg package manager tries to write extracted package files to disk but fails because there's no available space. On Debian-based systems like Ubuntu, the /boot partition is frequently the bottleneck—it accumulates old Linux kernel versions over time and can fill up completely. When dpkg attempts to write files (like new kernels), the operation fails, leaving the system in a broken state with incomplete package installations.
How do I fix "dpkg: error processing archive: failed to write to copy of file: No sp"?
This dpkg error occurs when your system runs out of disk space during package installation or updates. The /boot partition is often the culprit, filled with old kernel images. Free up space by removing outdated kernels and clearing cache files.
What causes "dpkg: error processing archive: failed to write to copy of file: No sp"?
Too many old kernel images in /boot partition—each kernel can consume 50-200 MB of space. Linux distributions don't automatically clean these up during updates. The /boot partition is too small—many systems have only 500 MB to 1 GB allocated, which fills up after just 3-5 kernel updates. Large log files or package cache in /var/cache/apt accumulating over time without cleanup.
Is the "dpkg: error processing archive: failed to write to copy of file: No sp" 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