If your Linux system is warning you that there's no free disk space even though df
or similar tools show that there is disk space free, there are a few possible explanations. Here's how to diagnose and fix the issue.
Open a terminal and run:
df -h
Look for the root (/) partition. You might see something like:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 42G 8.0G 84% /
So in this case, 16% free (8.0G available) — seems okay at first glance. But that doesn't always tell the whole story.
Linux filesystems also have inodes, which track metadata for files. If you run out of inodes, you can’t create new files even if you have disk space.
Run:
df -i
If the IUse% is 100% for any mounted filesystem, you’ve run out of inodes. This usually happens if you have tons of tiny files, e.g. in /tmp
, /var
, or cache directories.
You can check which directories are using up the most space:
sudo du -hxd1 / | sort -hr | head -20
Look for heavy directories like /var
, /tmp
, /home
, or /snap
.
find /home -xdev -type f | cut -d/ -f1-4 | sort | uniq -c | sort -nr | head
What it does:
find / -xdev -printf '%h\n'
— prints the directory (parent path) of each file (inode).sort | uniq -c
— counts how many times each directory appears (i.e., how many files are in each).sort -nr
— sorts numerically, descending.head -20
— shows the top 20 directories by inode usage.-xdev
prevents crossing into other mounted filesystems (like /proc
, /mnt
, /media
).This is another handy command to check top-level inode usage in /:
for i in /*; do echo "$i: $(find "$i" -xdev -type f | wc -l) files"; done | sort -k2 -nr | head
This tells you roughly how many files (inodes) exist in each major directory.
Sometimes, log files or temp files are deleted but still open by a running process — they still take up space.
Check with:
sudo lsof | grep deleted
If you see big files still held open, find the process ID and restart it:
sudo systemctl restart <service-name>
Or kill the PID:
sudo kill -9 <PID>