Today i had a customer who had an interesting problem. They were getting the message ‘disk is full’ despite having plenty of free space. Luckily for him, my first thought was ‘inodes?’
I logged in and checked his inode usage
[email protected]:# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/xvda1 525312 524844 468 100% /var
root 65579 27 65552 1% /
home 65579 2 65577 1% /home
local 65579 2696 62883 5% /usr/local
usr 65579 1 65578 1% /usr
This shows that all the inodes on the disk itself are full.
I used the following script to determine where the inode usage was most
[email protected]:/# for i in `ls -1A`; do echo “`find $i | sort -u | wc -l` $i”; done | sort -rn | head -5
I tracked it down to /var/www/vhosts/ and all the domain’s web files in there. Just remove all folders and files. It will release space for your inodes.
I used a find to then find any that were older than 10 days
[email protected]:/# cd /var/www/vhosts
# find ./ -type f -mtime +10 | wc -l
High inode usage is usually caused by a massive number of small files. In this case the session files are normally stored somewhere temporary and removed when not in use. Either there could have been a bug in the code not removing them or it was a higher traffic website.
You can delete files older than 10 days if you want with the following command
find ./ -type f -mtime +10 | xargs rm