inaabi / Guides / No space left on device
No space left on device
See whether the disk is out of blocks or out of inodes, find the directory that grew, and remove only that file.
Tested on Ubuntu 22.04.5 LTS and Debian 12 (bookworm), 2026-12-04.
df shows 100%, or a write fails with No space left on device. One filesystem is out of data blocks, or it is out of inodes. Those are different problems. A filesystem can have free space and still refuse a new file.
Look at which filesystem is full and which directory grew. Do not delete a file until you know what it is. Deleting the wrong one is not undone by freeing the blocks.
Tested on Ubuntu 22.04.5 LTS, 2026-12-04, in a throwaway container. The full and empty numbers below are from an 8 MiB tmpfs and a 4 MiB tmpfs limited to 32 inodes, so the shape of the output is what you are checking, not the size. df -hP and the No space left on device write were also run on Debian 12 (bookworm) the same day. du, find, and the inode case were run on Ubuntu 22.04.5.
Confirm which filesystem
df -hP -x tmpfs -x devtmpfs
df -iP -x tmpfs -x devtmpfs
-h prints sizes in MiB and GiB. -P is one line per filesystem, which is the line you can trust in a script. -i prints inodes. -x skips the virtual filesystems so they do not look like a second full disk.
On the test filesystem, a full disk looks like this:
Filesystem Size Used Avail Use% Mounted on
tmpfs 8.0M 8.0M 0 100% /mnt/full
The write that hit the limit:
dd: error writing '/mnt/full/fill': No space left on device
A second write fails the same way. The shell created the target file and then could not fill it, so a 0-byte file can appear beside the large one:
bash: line 16: echo: write error: No space left on device
0 /mnt/full/extra.txt
8388608 /mnt/full/fill
Out of inodes looks different. Use% for blocks can be near 0 while IUse% is 100%:
Filesystem Size Used Avail Use% Mounted on
tmpfs 4.0M 0 4.0M 0% /mnt/inodes
Filesystem Inodes IUsed IFree IUse% Mounted on
tmpfs 32 32 0 100% /mnt/inodes
bash: line 36: /mnt/inodes/i31: No space left on device
Creating a file needs an inode. Writing more bytes into a file that already exists does not. If df -i is at 100% and df -h is not, stop looking for one giant file. Look for a directory full of small ones.
Find what grew
Stay on that filesystem. -x and -xdev do not cross into another mount, so a full / does not make du walk a separate /var or /home.
du -xhd1 /var
find /var -xdev -type f -printf '%s %p\n' | sort -n | tail
Change /var to the mount from df. On the test mount, du and find named the file that filled it:
8.0M /mnt/full
8388608 /mnt/full/fill
Read the last column before you delete anything. A database file, a mail spool, and a log you still need all show up here. Size is not a reason to delete.
If the large path is a directory of tiny files and IUse% is 100%, the count of names is the problem. find /path -xdev -type f | wc -l tells you how many. Sort that directory by name and see whether one program created them.
Free the space
Remove the file you identified, or stop the program that is writing it and then remove it.
rm /mnt/full/fill
On a real system the path is the one find printed. After that remove, the test mount had room again:
Filesystem Size Used Avail Use% Mounted on
tmpfs 8.0M 4.0K 8.0M 1% /mnt/full
After the empty files were removed, the inode mount went from IUse% 100% to 7%:
Filesystem Inodes IUsed IFree IUse% Mounted on
tmpfs 32 2 30 7% /mnt/inodes
Then a new file can be created:
echo extra-after-undo > /mnt/full/after.txt
Package caches and journals are a common cause, and other guides cover them when the cache is the file you found. This page does not tell you to wipe /var. If the file is still growing as you watch du, the writer is still running. Stop that service, or the space returns as soon as you delete the file.
Verify
df -hP /var
df -iP /var
echo verify > /var/tmp/space-check.txt && rm /var/tmp/space-check.txt
Use the mount that was full. Avail is no longer 0, and the short write succeeds. IUse% is no longer 100% if inodes were the limit.
Undo
rm does not keep a copy. Undo means putting that file back from a backup you already have, or from the program that created it (a package reinstall, a log that will be written again). If you removed the wrong file, the free space is not the thing you want back.
The test undo is the other direction: the file that was removed was the one this test created, and the space came back. That is the check that you removed the file that was using the blocks.
Distro notes
df and du are coreutils. find is findutils. df -hP showed 100% and then 1% after the file was removed, on both Ubuntu 22.04.5 LTS and Debian 12 (bookworm). du -xhd1 and find -xdev -printf were run on Ubuntu 22.04.5. -printf is GNU find. On a non-GNU find, use find /var -xdev -type f -exec ls -l {} + and sort by size yourself.
df on the root filesystem of a server includes real disks. The test added -x tmpfs so container filesystems did not distract from the mount under test. On a server, run df without -x once and read the Mounted on column.
Related
- dpkg left a package half configured if a package configure script failed because the disk was full
- A high load with a full disk is this page. A high load with free space is a different problem.
Questions
Why does df show free space when I still get "No space left on device"?
The filesystem is out of inodes. df -iP shows IUse% at 100% while df -hP still shows free blocks. New files need an inode. Writing more data into a file that already exists does not.
Does deleting the file put the old contents back?
No. rm frees the blocks. The contents come back only from a copy you already have.
Sources
- df(1) on Debian bookworm
- du(1)
- find(1)
- df(1) on Ubuntu 22.04