Skip to content

Troubleshooting guide

No space left on device on Linux: how to fix it

A full disk breaks databases, logs and deployments in confusing ways. The fix depends on whether bytes, inodes or deleted-but-open files are the problem.

3 min read9 sectionsUpdated

On this page

Key points

  • df -h for bytes, df -i for inodes.
  • Deleted files held open keep using space until the process closes them.
  • Truncate a large active log, and do not delete it.
  • Root's 5 percent reserve can show as a full disk for other users.

What it means

The kernel returned ENOSPC, meaning a write could not be completed. Either all blocks or all inodes on that filesystem are used. The error names no file, and it may hit an unrelated service that happens to write next.

Common causes

  • Log files that are not rotated.
  • Deleted files still held open. Removing a log while the process runs frees nothing.
  • Inode exhaustion, often from session or cache directories.
  • Backups or core dumps left on the root volume.
  • Container data.

Diagnose it

Find which filesystem, then which directory, then look for files that exist only because something has them open.

bash
# Bytes and inodes per filesystem
df -h
df -i

# Biggest directories, staying on this filesystem
sudo du -xh / --max-depth=2 2>/dev/null | sort -h | tail -15

# Deleted files still held open
sudo lsof +L1 | sort -k7 -n | tail -10

# Directories with the most files (inode hunting)
sudo find /var -xdev -type f | cut -d/ -f1-4 | sort | uniq -c | sort -rn | head

Fixes

To free space safely, truncate an active log rather than deleting it: sudo truncate -s 0 /var/log/app.log. For a deleted file still open, restart or signal the process holding it. Clean package caches with apt clean, and rotate logs with logrotate using copytruncate or a reopen signal. Limit journald with SystemMaxUse= in journald.conf. Then expand the volume if growth is legitimate. Check every database afterwards, since a failed write may have left it needing recovery.

Catch it automatically

Alert at 80 and 90 percent, and alert on the forecast: a disk that will be full in four hours is urgent even at 60 percent. Infrastructure monitoring tracks bytes and inodes per mount. Do not forget mounts other than the root volume.

Frequently asked questions

Why is df full when du shows less?

Deleted files held open by a process still use space. Find them with lsof +L1.

Can a disk be full with free bytes?

Yes, when all inodes are used. Check with df -i.

Is it safe to delete files in /var/log?

Old rotated files are usually safe. For an active log, truncate it instead.

Watch your own site and services with VitalRix

Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.