CentOS 6 – Inodes full – can’t delete folder containing files

centospostfix

I have a CentOS 6 server at rackspace with 40GB of space. My server kept crashing with 'no space left on device' errors but there is over 50% free.

When I run df-i this is the output:

/dev/xvda1           2490368 2490351      17  100% /

I traced the problem to postdrop I think. Before I disabled postfix and postdrop the inodes would fill up immediately as soon as I freed any up.

From what I can see, there are thousands upon thousands of files being created in /var/spool/postfix/maildrop. The folder itself is 67MB. I can't "ls" the folder, I've tried to "rm -rf maildrop/" which just hangs for a long time.

How can I remove this folder. I don't even use mail on the server so I've disabled postfix and postdrop and sendmail.

drwx-wx---. 2 postfix postdrop  67M Dec 18 18:25 maildrop 

Just wanted to update:

ls -1 | xargs -I{} rm {}

the above command solved the problem

It took 48 hours on and off. There appeared to be almost 2,000,000 files in the /var/spool/postfix/maildrop folder.

Best Answer

If you have a directory full of files, normally you can not just remove all files with rm

Try with:

find /path/to/directory -type f -exec rm {} \;

Or try with:

ls -1 /path/to/directory | xargs -I{} rm {}

In other words you have to try to split the command in two, a part that handle the files and another that remove the files.

When you have a zillion of files into one directory you can't remove files using commands like rm. because rm in any case iterate between all files and directory.

Related Question