How to fix E: Write error - write (28: No space left on device) in APT

APTINTERMEDIATEHIGHUpdated Jul 3, 2026ยท 297 views

This error occurs when your disk or partition is full, preventing apt from writing packages or metadata. It can also occur when inodes are exhausted, even with free disk space remaining. Fix it by cleaning up disk space, removing old kernels, purging cache files, or extending storage.

Quick fix

Fixes E: Write error - write (28: No space left on device)

df -h
  1. Check disk usage and identify the full partition
  2. Clean apt package cache
  3. Remove old and unused packages
  4. Handle /boot partition full (kernel-related)
apt โ€” error
df -h
E: Write error - write (28: No space left on device)

What this error means

The "E: Write error - write (28: No space left on device)" error indicates that apt cannot write files to disk because your filesystem is full. This can happen for two reasons: actual disk space exhaustion (no free blocks) or inode exhaustion (no free file metadata slots). Even if `df -h` shows 50% free space, running out of inodes will still trigger this error. The write operation fails at the system level (errno 28), preventing apt from completing package installations or updates.

Typical symptoms

  • apt update, apt upgrade, or apt install commands fail with write error
  • Error occurs even though you believe you have disk space available
  • Running `df -h` shows most partitions have free space, but /var or /boot may be full
  • Software updates cannot be downloaded or installed
  • System stops responding during apt operations
  • Previous apt operations may have been interrupted, leaving incomplete files

Common causes

  1. Root partition (/) or /var partition is full from large files or logs
  2. /boot partition is full from multiple kernel versions (common issue)
  3. Apt cache contains old .deb packages that were never cleaned
  4. Log files in /var/log have grown excessively without rotation
  5. Inode exhaustion from countless small files, even with free disk blocks
  6. Temporary files or cache files from other applications consuming space
  7. Previous interrupted apt operations left partial or orphaned files

How to fix "E: Write error - write (28: No space left on device)"

1Check disk usage and identify the full partition

First, determine which partition is full:

bash
df -h

This shows you which mountpoint (/, /var, /boot, etc.) is at 100%. Also check inode usage:

bash
df -i

If IUse% is 100% for any partition even though block usage is low, you have inode exhaustion. Note which partition needs space freed.

2Clean apt package cache

The apt cache often contains old downloaded .deb files. Clean them:

bash
sudo apt clean

This removes all cached package files. For aggressive cleaning (removes partial packages too):

bash
sudo apt autoclean

Autoclean keeps only packages for currently installed versions, removing older version packages you may never use again.

3Remove old and unused packages

Autoremove deletes packages that were dependencies for other packages but are no longer needed:

bash
sudo apt autoremove --purge

The --purge flag also removes configuration files. This often frees significant space if you have upgraded your system multiple times.

4Handle /boot partition full (kernel-related)

If df -h shows /boot is full, you have multiple kernel versions installed. List installed kernels:

bash
dpkg -l | grep linux-image

Keep the current kernel and one previous kernel as backup. Remove old ones:

bash
sudo apt remove linux-image-<old-version>

Replace <old-version> with versions shown in the previous command (not the current running one). You can find your current kernel with:

bash
uname -r
5Clean up log files

Log files in /var/log can grow extremely large. Safely clean them:

bash
sudo du -h /var/log | sort -h | tail -20

This shows the largest log files. Remove old compressed logs:

bash
sudo rm /var/log/*.gz /var/log/*.old /var/log/*.[0-9].gz

For active logs, truncate them (don't delete, just empty):

bash
sudo truncate -s 0 /var/log/syslog
sudo truncate -s 0 /var/log/auth.log
6Find and remove large files consuming space

Use du to find the largest directories:

bash
sudo du -h --max-depth=1 / | sort -h

For deeper investigation of the largest culprits:

bash
sudo du -h --max-depth=2 /var | sort -h | tail -10
sudo du -h --max-depth=2 /home | sort -h | tail -10

Common space hogs: /var/cache, /var/log, /home (user files), and /tmp. Once identified, remove unnecessary files manually or with apt clean commands.

7Verify space is freed and retry apt

After cleanup, verify space is available:

bash
df -h

If /var or the partition containing /var/cache/apt is now below 90%, retry your apt command:

bash
sudo apt update
sudo apt upgrade

If you still get the write error, check which specific partition is still full and target cleanup there.

8Handle inode exhaustion (if disk space shows free but error persists)

If df -i shows 100% IUse% but df -h shows free space, you have inode exhaustion. Find directories with excessive small files:

bash
find /var/log -type f | wc -l
find /var/cache -type f | wc -l
find /tmp -type f | wc -l

Remove small cached files:

bash
sudo rm -rf /var/cache/apt/archives/*
sudo rm -rf /tmp/*
sudo find /var/log -type f -delete

Then verify:

bash
df -i
9Extend storage if cleanup doesn't free enough space

If space is still insufficient after cleanup, you may need to extend your partition. This requires:1. Unused space on your disk (check with fdisk -l), or
2. Another partition you can shrink

Extending a partition is advanced; ensure you have backups first. Tools like GParted (GUI) or fdisk/parted (CLI) can resize partitions. Alternatively, add a new disk and mount it at /var to distribute storage load.

Advanced notes

In cloud environments (AWS EC2, Azure, DigitalOcean), be aware that root volume sizes are fixed at launch; expanding requires detaching and resizing the volume, then rebooting. Docker containers inherit host filesystem limits; if running apt in a container, you're constrained by the container's host disk. WSL2 allocates a virtual disk; use wsl --manage <distro> --set-sparse true to reclaim space. For servers running unattended-upgrades, check /var/log/unattended-upgrades/ for large logs from repeated failed upgrades. Use logrotate to automate log rotation: edit /etc/logrotate.conf to compress and archive logs, freeing space automatically. For production systems, set up monitoring (Nagios, Zabbix, or cloud provider alerts) to trigger at 80% disk usage, preventing this error in the future.

Frequently asked questions

What does "E: Write error - write (28: No space left on device)" mean?
The "E: Write error - write (28: No space left on device)" error indicates that apt cannot write files to disk because your filesystem is full. This can happen for two reasons: actual disk space exhaustion (no free blocks) or inode exhaustion (no free file metadata slots). Even if df -h shows 50% free space, running out of inodes will still trigger this error.
How do I fix "E: Write error - write (28: No space left on device)"?
This error occurs when your disk or partition is full, preventing apt from writing packages or metadata. It can also occur when inodes are exhausted, even with free disk space remaining. Fix it by cleaning up disk space, removing old kernels, purging cache files, or extending storage.
What causes "E: Write error - write (28: No space left on device)"?
Root partition (/) or /var partition is full from large files or logs /boot partition is full from multiple kernel versions (common issue) Apt cache contains old .deb packages that were never cleaned
Is the "E: Write error - write (28: No space left on device)" 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