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
Diagnose it
Find which filesystem, then which directory, then look for files that exist only because something has them open.
# 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 | headFixes
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.
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.
Related reading
- High load average on Linux: what it means and how to fix it: Understand Linux load average: how it relates to CPU count, why I/O wait raises it with idle CPUs, and how to find the processes responsible using vmstat.
- High iowait on Linux: how to find the cause: Diagnose high iowait on Linux with iostat and iotop: read await and %util correctly, find the process doing the I/O, and fix slow queries and swap.
- JavaScript heap out of memory: how to fix it in Node.js: Fix FATAL ERROR: JavaScript heap out of memory. Set --max-old-space-size correctly, handle build-time failures and find runtime leaks with heap snapshots.
- ERR_ADDRESS_UNREACHABLE: how to fix it: Fix ERR_ADDRESS_UNREACHABLE: no route to the server, wrong IP in DNS, IPv6 problems, private addresses and firewalls, for visitors and server owners.
- ERR_INTERNET_DISCONNECTED: how to fix it: Fix ERR_INTERNET_DISCONNECTED in Chrome: reconnect Wi-Fi, check the router, disable proxies and VPNs, reset network settings, and when apps say offline.
- Cloudflare error 1016 "Origin DNS error": how to fix it: Fix Cloudflare error 1016 Origin DNS error: CNAME records pointing to names that do not resolve, deleted origins and load balancer pools, with checks.
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.