| title | Linux No space left on device | |||||
|---|---|---|---|---|---|---|
| slug | linux-no-space-left-on-device | |||||
| technologies |
|
|||||
| severity | high | |||||
| tags |
|
|||||
| related |
|
|||||
| last_reviewed | 2026-06-27 |
write error: No space left on device
$ touch /var/log/app.log
touch: cannot touch '/var/log/app.log': No space left on device
No space left on device is the userspace message for the ENOSPC errno (28).
It is returned by any write (write(), creat(), mkdir(), rename) when the
target filesystem cannot allocate the space the operation needs. Almost always
this means the filesystem's data blocks are full, but the same message is
returned when inodes are exhausted even though free blocks remain β a common
trap. The error surfaces from applications, package managers, log writers, and
databases the instant they try to grow a file.
- linux (filesystem / VFS layer)
high β services that cannot write logs, sockets, lock files, or data abort or hang. A full root filesystem can prevent logins and break package management, turning a single full mount into a host-wide outage.
- Unrotated or runaway log files filling
/varor/. - Large files left behind (core dumps, temp files, old releases, big tarballs).
- Deleted-but-open files whose blocks aren't freed because a process still
holds the file descriptor (
dfshows full,dushows less). - Inode exhaustion β millions of tiny files (see related error); blocks free but
ENOSPCstill returned. - A filling thin-provisioned volume or a full container overlay.
A filesystem tracks free data blocks and free inodes separately. A write that
needs a new block fails with ENOSPC when no free blocks exist; a create that
needs a new inode fails with the same ENOSPC when no free inodes exist. The
deleted-but-open case is the subtlest: unlink() removes the directory entry,
but the kernel only reclaims the blocks when the last open file descriptor is
closed. Until then df (which reads filesystem accounting) reports the space as
used while du (which walks visible files) cannot see it.
# Block usage per mounted filesystem β find the full mount
df -h
# Inode usage per filesystem β rules in/out inode exhaustion
df -i
# Biggest directories under the full mount (start at its root)
du -xh --max-depth=1 /var 2>/dev/null | sort -rh | head -20
# Deleted files still held open (space not reclaimed)
lsof -nP +L1 2>/dev/null | grep -i deleted
# Kernel messages β quotas, fs errors around the failure
dmesg -T | grep -iE 'no space|enospc|quota'$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 50G 0 100% /
$ df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 3276800 102311 ... 4% /
Here Use% 100% with healthy IUse% confirms a block problem, not inodes.
If lsof +L1 lists a multi-GB deleted log still open, the space is trapped by a
running process.
-
Find and remove or truncate the offender. To reclaim a deleted-but-open file without restarting the process, truncate via its fd:
: > /proc/<pid>/fd/<n> # zero the still-open deleted file
-
Rotate/compress logs immediately if logs are the cause (
journalctl --vacuum-size=500Mfor the journal). -
Delete stale artifacts (old releases, core dumps in
/var/crash,/tmp). -
If it is genuinely full with valid data, grow the filesystem/volume (
lvextend+resize2fs, or expand the cloud disk). -
Restart the process holding a deleted file if you cannot truncate it safely.
df -h /var # Use% well below 100, Avail restored
touch /var/log/test && rm /var/log/test && echo OK # writes succeed again- Configure
logrotateand journaldSystemMaxUse=limits. - Alert at 80% block usage, not at 100%.
- Put
/var/log,/tmp, and data on separate filesystems from/. - Cap core dumps (
ulimit -c,/proc/sys/kernel/core_pattern). - Monitor thin-pool and overlay usage on container hosts.
linux Β· disk Β· filesystem Β· enospc Β· production