How to fix dpkg: error processing archive: failed to write to copy of file: No space left on device in APT
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- Check available disk space and identify the problem partition
- Check your current kernel version to avoid removing it
- Remove old kernel images to free space
- Clear package cache to free additional space
df -hdpkg: 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
- 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.
- Container images or system snapshots taking up space in root filesystem when /boot is on the same partition.
- 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"
Run this command to see all partitions and their usage:
df -hLook 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:
du -sh /boot/*This will show large files (usually old kernels) taking up space.
Before removing kernels, identify which one is currently running:
uname -rThis outputs something like 5.15.0-84-generic. Make a note of this—DO NOT remove this kernel. List all installed kernels:
dpkg -l 'linux-*' | grep '^ii'You'll see multiple kernel versions. Identify the older ones that differ from your current kernel.
Replace 5.15.0-83-generic with the actual old kernel version from the previous step (one that's NOT your current kernel):
sudo apt-get remove --purge linux-image-5.15.0-83-generic
sudo apt-get remove --purge linux-headers-5.15.0-83-genericOr use autoremove to remove all unused kernels at once (safe, only removes unused ones):
sudo apt-get autoremove --purgeIf you get "No space left on device" even with autoremove, try removing the oldest kernel manually first to create space, then use autoremove.
Once you've freed some space, clean up the apt cache:
sudo apt clean
sudo apt autocleanapt clean removes all cached .deb files. apt autoclean removes only old cached packages. This can free up several hundred MB.
After freeing space, fix any incomplete package operations:
sudo apt-get -f installThis repairs dependencies and completes any interrupted installations. Then try your original command again:
sudo apt update
sudo apt upgradeAdvanced 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.