CleanMate

All guides · Ubuntu · Updated

Ubuntu says the disk is full, but df shows free space: inodes, deleted files and reserved blocks

Why Ubuntu reports "No space left on device" while df -h still shows free space, or frees nothing after you delete files: inodes run out, deleted files a process keeps open, ext4 reserved blocks, a full /tmp or /boot, the journal, snaps and Docker, with the command to check and fix each.

Install on Ubuntu — free and open source

CleanMate Space Lens on Ubuntu listing the folders of a home folder by size

apt stops with “No space left on device”, a build fails, or the desktop warns about low disk space, yet df -h shows gigabytes free. Or the opposite: you delete a 20 GB file and df does not move. Both have a handful of causes, and each one is checked with one command. If the disk is simply full, start with how to free up disk space on Ubuntu instead; this guide is for when the numbers don’t add up.

First see which filesystem is full. The error is about the filesystem the program writes to, which is not always /:

df -h          # space on every mounted filesystem
df -i          # inodes (file slots) on every mounted filesystem

Inodes ran out

Every file and folder uses one inode, and ext4 creates a fixed number of them when the filesystem is made. Millions of tiny files (a mail queue, a cache, session files, a node_modules tree copied many times) can use them all while gigabytes stay free. df -i then shows IUse% at 100%.

Find the folder with the most files:

sudo du --inodes -x -d 1 / 2>/dev/null | sort -n | tail
sudo du --inodes -x -d 1 /var 2>/dev/null | sort -n | tail   # go one level deeper where the count is

Delete those files with the tool that made them when there is one (apt clean, journalctl --vacuum-time, the app’s own cleanup), or the folder itself if it is a cache. The number of inodes on ext4 cannot be raised without making the filesystem again.

A deleted file is still open

Deleting a file removes its name, but the space comes back only when the last program that has it open closes it. A log file deleted while a service still writes to it is the classic case: df stays full, du no longer counts it, and the two disagree.

sudo lsof +L1                 # open files with no name left on disk
sudo lsof +L1 | sort -k7 -n | tail   # the biggest ones last

Restart the program in the COMMAND column (sudo systemctl restart <service>, or quit and reopen the app) and the space returns. To empty a log without restarting its writer, truncate it instead of deleting it: sudo truncate -s 0 /var/log/<file>.

Reserved blocks on ext4

ext4 keeps 5% of the filesystem for root, so the system can still write logs when users have filled it. df does not count that 5% as available, which is why Used plus Avail is less than Size; on a 1 TB disk that is about 50 GB. A program running as you sees the disk as full while root can still write.

sudo tune2fs -l /dev/<partition> | grep -i "reserved block count"

On the system disk, keep the reserve. On a data disk that only holds your files (a second drive, an external drive formatted ext4), you can lower it to 1% or 0:

sudo tune2fs -m 1 /dev/<partition>

Take the partition name from the first column of df -h.

/tmp, /boot or another small partition

df -h lists every filesystem. A program that writes to /tmp fails when /tmp is full, even if / is not; on Ubuntu /tmp is usually a folder of / but can be a tmpfs in memory (tmpfs in the first column). Ubuntu empties /tmp at every boot.

sudo du -xh -d 1 /tmp 2>/dev/null | sort -h | tail

Delete only the files of programs that are not running. A full /boot is its own case: old kernels, removed with apt, never with rm. See /boot is full: remove old kernels.

The journal, snaps and Docker

Three things fill /var without showing in your home folder, so a disk analyzer pointed at ~ misses them:

journalctl --disk-usage
sudo du -sh /var/lib/snapd /var/lib/docker /var/lib/flatpak 2>/dev/null

Still no idea where the space went

Walk the disk folder by folder from the terminal, as root so nothing is hidden, and stay on one filesystem with -x:

sudo du -xh -d 1 / 2>/dev/null | sort -h | tail

Then go one level deeper where the space is. The full method, and the tools that draw it (ncdu, Disk Usage Analyzer): find what is using disk space from the terminal.

How CleanMate does it

CleanMate 2.7.0 for Ubuntu (all Ubuntu features) clears the usual causes in one scan and shows each before it removes anything:

It does not change reserved blocks, count inodes or restart programs that hold deleted files: for those, use the commands above. A Space Lens view of the whole system disk, with the reason each system folder stays, is coming in the next release.

One frequent hidden tenant: Timeshift snapshots, which live in a top-level /timeshift folder outside your home.

FAQ

Why does df show a /dev/loop device at 100%? It is a snap package mounted read-only. It is always full and never grows; remove old snap revisions to get space back.

Is it safe to set reserved blocks to 0? On a disk with only your own files, yes. On the system disk, keep at least 1%, so root can still log in and write when the disk fills.

du and df show different numbers. Which is right? Both. df counts the filesystem, including reserved blocks, deleted files still open and files you cannot read; du counts only the files it can see. A big gap means one of the causes above.

Skip the commands

Open source — star it on GitHub: CleanMate for Ubuntu

How CleanMate decides what is safe to remove →