This error occurs when your system doesn't have sufficient free disk space to complete an APT package upgrade or installation. The upgrade process needs temporary space for package files, and when the disk is full, the operation fails and is aborted.
APT (Advanced Package Tool) needs temporary disk space to download and install package files before completing the upgrade. This error indicates that your system lacks the required free space. The issue commonly occurs in the /boot, /var, or / (root) partitions, where APT stores downloaded .deb files in /var/cache/apt/archives/ and unpacks them during installation. When any of these partitions reaches capacity, the upgrade process halts to prevent further system issues.
Run df -h to see which partitions are full. Pay special attention to /boot, /var, and / (root). You can also use sudo du -h --max-depth=1 /var | sort -h | tail -n 10 to identify the largest directories consuming space.
Remove cached .deb files that are no longer needed:
sudo apt-get cleanFor a more aggressive cleanup that also removes partial package files:
sudo apt-get autocleanThis typically frees up several hundred MB to several GB, depending on your system history.
Old kernel versions consume significant space in /boot. Remove them with:
sudo apt-get autoremoveFor a more thorough cleanup with headers:
sudo apt-get autoremove --purgeIf autoremove doesn't remove enough, you can manually purge specific old kernels:
sudo apt-get purge linux-headers-X.X.X-XX-generic linux-image-X.X.X-XX-genericReplace X.X.X-XX with the kernel version you want to remove (use uname -r to see your current kernel).
Large log files in /var/log can consume significant disk space. Check which logs are large:
ls -lhS /var/log | head -20If journalctl is using excessive space, trim it:
sudo journalctl --vacuum-size=64MYou can also rotate or delete individual large log files:
sudo truncate -s 0 /var/log/syslogBeyond kernels, remove other unused packages:
sudo apt-get autoremove --purgeYou can also check for config files from removed packages:
sudo dpkg --list | grep '^rc' | awk '{print $2}' | xargs sudo apt-get remove --purgeCheck disk usage again:
df -hEnsure you have at least 5-10% free space on all partitions, especially /boot (which should have at least 500MB free). For a safe upgrade, aim for at least 20% free space.
Once you've freed up sufficient space, retry the upgrade:
sudo apt-get update
sudo apt-get upgradeOr for a full distribution upgrade:
sudo do-release-upgradeIf you have a /boot partition that's persistently too small, consider adjusting initramfs compression. By default, /boot uses lz4 compression which has a poor compression ratio. You can achieve better compression by editing /etc/initramfs-tools/initramfs.conf and setting COMPRESS=xz instead of the default. This significantly reduces initramfs size at the cost of slightly longer boot times. After editing, run sudo update-initramfs -u to apply the change.
For systems using LVM (Logical Volume Manager), you can expand the /var partition without reinstalling:
sudo lvextend -L +10G /dev/mapper/vg0-var
sudo resize2fs /dev/mapper/vg0-varReplace vg0-var with your actual LVM volume name (check with sudo lvs). If you're not using LVM and /var is on a separate partition, you may need to use tools like GParted or resize your disk and partition table manually.
Virtual machine users can expand the virtual disk in their hypervisor (VMware, VirtualBox, etc.), then resize partitions within the guest OS using similar LVM or GParted techniques.
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
E: Sub-process /usr/bin/dpkg returned an error code (1) during kernel installation
How to fix "dpkg returned an error code (1)" in APT kernel installation
dpkg: dependency problems prevent configuration of triggers
dpkg: dependency problems prevent configuration of triggers in apt