A Magento site went down with a bunch of error messages saying that:
Warning: SessionHandler::Read() No space left on device
First thought, ok, that’s easy. I can just log in and clean up some cache data or log files and everything will just be fine after that.
Turns out, after running df -h, there are still tons of spaces left on the server.
So, what’s the deal?
Here come the inodes.
The inode (index node) is a data structure in a Unix-style file system that describes a file-system object such as a file or a directory. Each inode stores the attributes and disk block location(s) of the object’s data. File-system object attributes may include metadata (times of last change, access, modification), as well as owner and permission data.
Basically, if you have a lot of big files, you will most likely run out of space, the physical real space. But if you have a lot of tiny small files, you will likely run out of inodes. When that happens, you will get the out-of-space message even though there is still a lot of free space left on your drive.
To find out the number of inodes,
df --inodes or df -i
Next step, let’s identify which file or folder consumes the inodes.
find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n
Once find out, dive into that folder and clean things up. In my case, it’s the folder /var/lib/php/sessions that consumed all the inodes.
sudo rm -rf /var/lib/php/sessions/ sudo mkdir /var/lib/php/sessions/ && sudo chmod 1733 /var/lib/php/sessions/