The error says the disk is full. df -h says the disk is 1 percent used. Both are telling the truth. “No space left on device” is the message Linux gives for several different kinds of full, and only one of them is about gigabytes. Three of them were reproduced on purpose below, on a small 256 MB ext4 disk image on Ubuntu 24.04, along with the commands that tell them apart and the fix for each.
Every file needs an inode
What an inode is
On ext4 and most traditional Unix filesystems, every file and directory is described by an inode: a small record holding its owner, permissions, timestamps and the locations of its data. The file’s name lives separately, in its directory. An empty file uses no data blocks but still uses one inode.
ext4 decides the count once
A freshly formatted 256 MB ext4 image reported:
$ df -h mi
/dev/loop1 224M 24K 206M 1% /var/tmp/fs/mi
$ df -i mi
/dev/loop1 65536 11 65525 1% /var/tmp/fs/mi
df -i shows inodes instead of bytes: 65,536 in total, fixed when the filesystem was created. The mke2fs manual for Ubuntu 24.04 warns that the bytes-per-inode ratio cannot be changed after the filesystem is created, so the only real fixes for running out are deleting files or rebuilding the filesystem with more inodes. Some newer filesystems, such as XFS and Btrfs, allocate inodes as needed and rarely hit this wall.

Failure 1: out of inodes
Reproducing it
A small script created empty files in a single folder, the way a web application might pile up session files or a mail system might pile up messages, until the system refused:
stopped after 65523 files: [Errno 28] No space left on device
The disk afterward:
$ df -h mi
/dev/loop1 224M 2.0M 204M 1% /var/tmp/fs/mi
$ df -i mi
/dev/loop1 65536 65536 0 100% /var/tmp/fs/mi
$ echo "hello" > mi/new.txt
bash: mi/new.txt: No space left on device
Two megabytes used, 204 MB free, and not even a six-byte file could be written. Errno 28, ENOSPC, is the same error a truly full disk gives, which is why this one wastes so much time: the first thing everyone checks is df -h, and it looks fine.
Finding the culprit
$ du --inodes -x -d2 mi | sort -n | tail -3
65524 mi/cache/sessions
65525 mi/cache
65527 mi
du --inodes counts files instead of bytes, and -x keeps it on one filesystem. On a real server, running it from / with a depth of 3 or 4 usually points straight at the problem: an application cache, a mail queue, a temp directory, or a container’s layers.
Fixing it
$ find mi/cache/sessions -type f -name 'sess_*' -delete
Deleting 65,524 files took about half a second, and df -i dropped back to 13 inodes in use. Then a detail worth knowing: the sessions directory itself still measured 1,974,272 bytes. On ext4, a directory grows as entries are added but does not shrink when they are removed, so a folder that once held millions of files can stay slow to list. Moving the surviving files into a fresh directory and removing the old one reclaims that space and speed. The lasting fix is upstream: a cleanup job or a setting that stops the application from keeping every session forever.
Planning ahead
For a disk that will hold millions of small files, the inode count can be chosen when it is formatted. Three 2 GB test images formatted with different options came out very differently:
| mkfs.ext4 option | Inodes created |
|---|---|
| default | 131,072 |
-i 4096 (one inode per 4 KB) |
524,288 |
-T largefile |
2,048 |
The largefile profile suits a disk of video files, where a few thousand inodes is plenty and the space goes to data instead. For a mail server or a cache, the default can be far too few, and the choice cannot be undone later without reformatting.
Failure 2: space held by a deleted file
Reproducing it
A program opened a log file, wrote 150 MB to it and kept it open. Then the file was deleted:
$ df -h mi
/dev/loop1 224M 152M 54M 74% /var/tmp/fs/mi
$ rm mi/app.log
$ df -h mi
/dev/loop1 224M 152M 54M 74% /var/tmp/fs/mi
$ du -sh mi
2.0M mi
The file was gone from the directory, du added up only 2 MB of files, and the disk still showed 152 MB used. The unlink(2) manual explains why: when the last name of a file is removed while a process still has it open, the file will remain in existence until the last file descriptor referring to it is closed.
Finding it
$ lsof +L1
python3 27800 3w 157286400 0 15 /var/tmp/fs/mi/app.log (deleted)
lsof +L1 lists open files with fewer than one link, which means deleted. The output named the process, its ID, the file descriptor and the size. When the process was stopped, the disk dropped immediately to 2.0 MB used.
This is the classic outcome of deleting a huge log file to free space while the service writing it keeps running. The safer move is to empty the file in place, truncate -s 0 app.log or : > app.log, which frees the space even while it is open, or to restart the service after deleting the file, or to use the service’s own log rotation.

Failure 3: the reserve only root can use
Reproducing it
The tune2fs manual describes the reserved-blocks percentage, normally 5 percent, as a share of the filesystem only privileged processes may allocate, kept to avoid fragmentation and to let system daemons keep working when the disk fills. On the test image that was 3,276 blocks of 4 KB, about 13 MB.
An ordinary user filled the disk with a single large file and was stopped at 203 MiB, with df showing 916 KB still available and 100 percent used. Root then wrote another 13 MiB before getting the same error.
What that means
A regular application can hit “no space left on device” while root still has room, which is why administrators sometimes cannot reproduce a user’s error. On a system disk, that reserve is valuable: it lets root log in and clean up. On a large data disk used only for storage, 5 percent can be hundreds of gigabytes, and tune2fs -m 1 lowers the reserve without reformatting.
Failure 4: a small filesystem in memory
Reproducing it
Paths like /tmp and /dev/shm are often not on the main disk at all but on tmpfs, a filesystem whose contents, according to the tmpfs(5) manual, reside in virtual memory and can spill into swap. A 16 MB tmpfs was mounted for the test, and a 20 MB write was attempted:
dd: error writing '/var/tmp/fs/tmpt/blob': No space left on device
17+0 records in
At the same moment, df -h showed the tmpfs at 100 percent while the machine’s root filesystem had 20 GB free. A program writing temporary files to a tmpfs /tmp, such as a build tool, a browser or a database sort, fails exactly the same way as on a full disk, and checking df -h / will never find it.
Limits on both bytes and files
The same manual describes size= as the upper limit on the filesystem’s size, 50 percent of RAM by default, and nr_inodes= as the maximum number of inodes, which by default scales with the machine’s memory. A second test tmpfs mounted with nr_inodes=1000 reported exactly 1,000 inodes in df -i, so a memory-backed filesystem can run out of files too. Both limits can be raised on the fly with a remount, mount -o remount,size=2G /tmp, as long as the RAM is really there to back it.

A troubleshooting order
Four commands, in order
df -h: is the filesystem actually full of data?df -i: are the inodes used up?lsof +L1: are deleted files still holding space open?du -xh -d2 /path | sort -h: where is the data, ifdfandduagree?
Each answer points to a different fix: delete or move data; delete many small files or rebuild with more inodes; restart or truncate the process holding a deleted file; or, if only root can write, recognize that the disk really is almost full.
Other places the same error comes from
The same ENOSPC also appears when a disk quota runs out for one user, when a small tmpfs such as /tmp or /dev/shm fills up even though the main disk has room, and when Btrfs runs out of space for its own metadata. df on the exact path that failed, not just on /, shows which filesystem is involved.
Three different disks, all reporting the same five words. The fix starts with refusing to trust the first df that looks fine.
Sources
- tmpfs(5), Linux manual page: https://man7.org/linux/man-pages/man5/tmpfs.5.html
- mke2fs(8), Ubuntu 24.04 manual page: https://manpages.ubuntu.com/manpages/noble/man8/mke2fs.8.html
- unlink(2), Linux manual page: https://man7.org/linux/man-pages/man2/unlink.2.html
- tune2fs(8), Ubuntu 24.04 manual page: https://manpages.ubuntu.com/manpages/noble/man8/tune2fs.8.html
