Linux disk full errors but disk has space

Linux disk full errors but disk has space

Desktops, Filesystems, Linux, Servers, Slider No Comments on Linux disk full errors but disk has space

Today I had a customer reporting a wordpress error when uploading images. "Missing a temporary folder"

Checked file permissions on /tmp – they were fine.

But is /tmp the location of the temporary folder for the site? Went to add a new file for a quick php_info(); and got a "disk space full error". Ahhh, that explains it.

Run "df -h" to check diskspace and the drives were between 0% – 18% full, loads of space.

But knowing the way that linux file systems work having encountered this issue before I know the problem and the solution.


Inodes are a finite resource on most linux file systems which limit the total maximum number of files.

They work in a similar way to an index or table of contents at the start of a book.

Both the book and the index were created at the same time, completely empty but with a suitable number of index entries (inodes) for the pages (files) in the book.

On a normal system you run out of disk space well before you run out of inodes – this server had 38GB diskspace and 4.9 million inodes meaning an average file size of 7.7KB would fill disk and inodes perfectly.

But if you get a server with an unusually large number of extremely small files the inodes limit can be an issue.

Increasing inode limits will normally require reformatting the disk so not good for a production machine – so the fix is to delete files.


First I located the source of the majority of files (inodes).

cd /

for i in `ls -1A | grep -v "\.\./" | grep -v "\./"`; do echo "`find $i | sort -u | wc -l` $i"; done | sort -rn | head -10

This showed I had 4.7M inodes in /var

cd var

for i in `ls -1A | grep -v "\.\./" | grep -v "\./"`; do echo "`find $i | sort -u | wc -l` $i"; done | sort -rn | head -10

The files were all in /var/spool

cd spool

for i in `ls -1A | grep -v "\.\./" | grep -v "\./"`; do echo "`find $i | sort -u | wc -l` $i"; done | sort -rn | head -10

/var/spool/exim4 was the culprit with 95% of my available inodes in use.

I didn't use exim4 on this server, it got installed as a dependency of something else I was using, so fine to go ahead and clear them all.

rm -f exim4

Waiting, waiting and waiting. I probably would have got a "too many arguments" error but didn't wait that long.

cd exim4

find . -type f -print -delete

Using find worked more reliably and was less resource intensive when it comes to deleting a few million files.

# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 4980736 217861 4762875 5% /

Problem solved!

Mark Walker

Related Articles

Leave a comment

You must be logged in to post a comment.

A collection of tips, tricks, reviews and discussion created by webmasters for webmasters.


Back to Top