Linux: No space left on device
The error names a filesystem, not the whole disk. Find which mount is full, check inodes and deleted-but-open files, and clear logs, caches and layers.

Introduction & Quick Summary
A process that worked an hour ago now fails every write:
$ echo "x" > /var/log/app/current.log
bash: /var/log/app/current.log: No space left on device
$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p1 118G 118G 0 100% /Quick answer: one filesystem — or its inode table — is full. No space left on device names the mount that holds the file you touched, not the disk as a whole, so a full /var breaks logs while /home still has room.
df -hT # which mount is at 100%
df -i # did inodes run out instead of blocks?
sudo du -xhd1 / | sort -h | tail -15
sudo lsof +L1 | head # deleted files still held open by a processFix according to what those three commands show. Blocks full means find and free real data; inodes full means millions of small files, usually sessions, mail queues or build caches; deleted-but-open files mean the space is already free on disk but still counted, and only restarting or truncating the holder releases it.
This guide covers how Linux accounts disk space, the four distinct ways a filesystem reports itself full, and the cleanup that is safe to automate versus the cleanup that quietly breaks a running service.
Core Mechanics, Signatures & Reproducible Setup
A filesystem has two independent limits: data blocks and inodes (metadata slots, one per file). A write fails with ENOSPC when either is exhausted, when the user's quota is exceeded, or when a temporary filesystem has hit its size cap.
df -h reports blocks; df -i reports inodes. Ext4 reserves 5% of blocks for root by default, so a filesystem can show 100% used and still accept writes from root.
df -hT /
# Filesystem Type Size Used Avail Use% Mounted on
# /dev/nvme0n1p1 ext4 118G 112G 0G 100% /
# ^ used ^ avail ignores the 5% reserve
sudo tune2fs -l /dev/nvme0n1p1 | grep -E "Reserved block count|Block count|Inode count"A reproducible full filesystem without touching the host disk:
mkdir -p /tmp/full && cd /tmp/full
dd if=/dev/zero of=big.img bs=1M count=64
mkfs.ext4 -q big.img
mkdir mnt && sudo mount -o loop big.img mnt
sudo dd if=/dev/zero of=mnt/fill bs=1M count=70 2>&1 | tail -2 # "No space left on device"
df -h mnt
sudo rm mnt/fill && sudo umount mntThe same message appears from a write to /tmp when /tmp is a tmpfs sized from RAM, from a Docker container whose overlay layer is capped, and from a Kubernetes pod that has exceeded ephemeral-storage.
Key Comparison Table
| Observation | Meaning | First move |
|---|---|---|
df -h at 100%, df -i low | real data fills the blocks | find large files under that mount |
df -h low, df -i at 100% | too many files | delete small-file directories |
df shows space, write still fails | deleted files held open | lsof +L1, restart the holder |
| Only one directory fails | quota or a separate mount | df that path, quota -s |
Fails on /tmp only | tmpfs or a small tmp partition | clean /tmp, check tmpfs size |
| Container write fails, host fine | overlay or ephemeral storage cap | prune images, raise limits |
| Path | Common cause | Safe cleanup |
|---|---|---|
/var/log | unrotated logs, journal | journalctl --vacuum-size=500M, rotate |
/var/lib/docker | images, build cache | docker system prune -af |
/var/lib/apt | cached .deb files | apt-get clean |
/home/*/.cache | build caches, browser data | per-tool cache clean |
/var/spool | mail or print queues | inspect, then drain |
/tmp | stale build artifacts | reboot or find -mtime +7 -delete |
| Symptom | Inode or blocks | Proof |
|---|---|---|
Many tiny files (sessions, node_modules) | inodes | df -i shows 100% |
| Few large files (images, backups) | blocks | du shows large paths |
Space doesn't return after rm | neither, held open | lsof +L1 lists the file |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
1. Find what is actually using the space
du without -x crosses into other mounts and reports their space as if it belonged to /, which produces nonsense totals:
sudo du -xhd1 / 2>/dev/null | sort -h | tail -15
sudo du -xhd1 /var 2>/dev/null | sort -h | tail -10
sudo find / -xdev -type f -size +1G -printf '%s\t%p\n' 2>/dev/null | sort -n | tailThe -xdev flag keeps the walk on one filesystem, which is exactly what df is measuring.
2. Space that does not come back after rm
A process holding a deleted file keeps its blocks allocated. The directory entry is gone, du reports nothing, and only the kernel knows:
sudo lsof +L1 | awk '$7 > 1000000 {print $1, $2, $7, $9}' | sort -k3 -n | tail
sudo truncate -s 0 /proc/1234/fd/7 # release the space without killing the process
sudo systemctl restart app # or restart the holderThis is the classic log-file case: a log removed with rm while the service still writes to it. Configuring logrotate with copytruncate avoids it.
3. Inode exhaustion
Millions of 4 KB files fill the inode table long before the blocks are full. Sessions, mail queues, and build directories are the usual sources:
df -i /
sudo find /var -xdev -type d -printf '%p\n' -exec sh -c 'c=$(ls -A "$1" | wc -l); [ "$c" -gt 20000 ] && echo "$c $1"' _ {} \; 2>/dev/null | sort -n | tail
find /var/lib/php/sessions -type f -mtime +1 -deleteOn ext4 the inode count is fixed at mkfs time, so the durable fix is fewer files or a filesystem rebuilt with more inodes — not more disk.
4. journald and logs
/var/log/journal grows without limit on systems without a cap. Journald's own vacuum is safer than deleting files:
journalctl --disk-usage
sudo journalctl --vacuum-size=500M
sudo journalctl --vacuum-time=14d
# persist a cap
sudo sed -i 's/^#SystemMaxUse=.*/SystemMaxUse=1G/' /etc/systemd/journald.conf
sudo systemctl restart systemd-journaldFor application logs, logrotate with size, rotate and compress keeps the directory bounded without manual intervention.
5. Containers and Kubernetes
Inside a container, the writable layer counts against the host unless a volume is mounted. Docker's build cache is often the largest single item:
docker system df
docker system prune -af --volumes
docker builder prune -afIn Kubernetes, a pod that writes to its own filesystem consumes ephemeral-storage; the kubelet evicts it with Evicted: ephemeral-storage in the pod events, and the node may show space while the pod cannot write.
kubectl describe pod <pod> | grep -A5 "Last State"
kubectl get events --field-selector reason=EvictedMount an emptyDir with a sizeLimit, or write to a PersistentVolume, so the limit is explicit.
6. Ext4 reserved blocks and quotas
On ext4, only root can use the reserved blocks, which is why a service account fails while sudo succeeds with df at 100%:
sudo tune2fs -m 1 /dev/nvme0n1p1 # lower the reserve from 5% to 1%
sudo tune2fs -l /dev/nvme0n1p1 | grep "Reserved block count"On filesystems with user quotas, the limit is per user rather than per mount:
quota -s
sudo repquota -aThe JSON formatter is useful for lsblk -J output when a machine has many volumes and you need to see which one backs a mount, and the regular expression tester helps pull the largest paths out of du output before deleting anything.
Common Compilation/Runtime Mistakes & Version Gotchas
- Deleting files with
rminstead of truncating. A held-open file keeps its blocks;: > filefrees them immediately. - Running
du /without-x. It reports other mounts and leads to deleting the wrong directory. - Deleting
/var/lib/dockerby hand. Docker's metadata and layers then disagree; usedocker system prune. - Assuming 100% means root can't write. The ext4 reserve keeps root working, which hides the problem from an interactive session while services fail.
- Clearing
/tmpon a live system withrm -rf /tmp/*. Some processes hold sockets and lock files there; delete by age instead. - Ignoring inodes.
df -hlooks healthy whiledf -iis at 100%, and the error is identical. - Forgetting snaps and container images.
/var/lib/snapdand/var/lib/containerdgrow silently;snap list --allshows old revisions that can be removed.
Official documentation: df(1) and tune2fs(8) reserved blocks.
Official references
primary documentationThe Linux documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit Linux work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related Linux guides
All Linux guidesnginx 502 Bad Gateway: upstream connection refused
The log line names the address and errno, which is the diagnosis. Fix the host, the start-up order, the buffers, or the timeout that actually fired.
Linux: Read-only file system (EROFS) on a mounted volume
EROFS is a mount condition, not a permission error. Read the kernel log first: I/O errors, a full thin pool, an ro fstab entry or a read-only root.
Linux Networking Diagnostics: ss, ip, dig, curl, and TCP Troubleshooting
A layer-by-layer path from interface to TLS that localises a failure in five commands, with the socket states and curl timings that identify each cause.
apt: The repository does not have a Release file
apt disables any repository whose Release file returns 404. Correct the suite name, move an end-of-life release to the archive host, or remove a dead repo.
More in Linux
All Linux guidesThe guides filed next to this one in Linux, in library order.