This afternoon, I found my site was not accessible when I tried it. So I went to the Webmin panel. It loaded, but with a warning, disk space is running out.

It is kind of urgent. All websites on this VPS have the problem, such as phpBB forum, etc.

OK. I ssh to the server. run the command as below.

davidyin@mail:~$ df -h --total
Filesystem Size Used Avail Use% Mounted on
tmpfs 794M 788K 793M 1% /run
/dev/sda3 194G 94G 91G 52% /
tmpfs 3.9G 288K 3.9G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 332M 1.5G 18% /boot
tmpfs 794M 0 794M 0% /run/user/1000
total 202G 95G 97G 50% -

There is a lot of disk space. Almost 50% is free. What is the problem?

I run another command to check the inodes.

davidyin@mail:~$ df -i
Filesystem       Inodes    IUsed   IFree IUse% Mounted on
tmpfs           1015989      731 1015258    1% /run
/dev/sda3      12976128 12956541   19587  100% /
tmpfs           1015989        4 1015985    1% /dev/shm
tmpfs           1015989        2 1015987    1% /run/lock
/dev/sda2        131072      332  130740    1% /boot
tmpfs            203197       18  203179    1% /run/user/1000

Now, I know the problem. The inode is full on the sda3.

What is an inode?
An inode is a file data structure that stores information about any Linux file except its name and data.

What are inodes used for?
Data is stored on your disk in the form of fixed-size blocks. If you save a file that exceeds a standard block, your computer will find the next available segment on which to store the rest of your file. Over time, that can get super confusing.

That’s where inodes come in. While they don’t contain any of the file’s actual data, it stores the file’s metadata, including all the storage blocks on which the file’s data can be found.

Information contained in an inode:

File size
Device on which the file is stored
User and group IDs associated with the file
Permissions needed to access the file
Creation, read, and write timestamps
Location of the data (though not the filepath)
Inodes are also independent of filenames. That means you can copy a single file, rename it, and still have it point to the same inode as the original.

Here is my situation. I have a lot of small files. Each file may be 1KB size. The disk space is not full, but the inodes are almost full.

I have to find the folder that holds these small files.

OK. I found it. It is the WordPress cache folder.

First I stop the Nginx Web service. Delete some files to give a space to run load the web server.

Second, I start the Nginx Web server, and log in to my blog(here) wp-admin page. Navigated to the W3 Total Cache plugin manage page, disable it.

Third, in SSH window, I removed all the files under myblog/wp-content/cache/.

After all these steps, it took me about three hours in step 3. I checked the inode and disk space again.

davidyin@mail:~$ df -h --total
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           794M  800K  793M   1% /run
/dev/sda3       194G   40G  145G  22% /
tmpfs           3.9G  300K  3.9G   1% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/sda2       2.0G  170M  1.7G  10% /boot
tmpfs           794M     0  794M   0% /run/user/1000
total           202G   40G  152G  21% -

davidyin@mail:~$ df -i
Filesystem       Inodes  IUsed    IFree IUse% Mounted on
tmpfs           1015989    736  1015253    1% /run
/dev/sda3      12976128 343001 12633127    3% /
tmpfs           1015989      4  1015985    1% /dev/shm
tmpfs           1015989      2  1015987    1% /run/lock
/dev/sda2        131072    324   130748    1% /boot
tmpfs            203197     18   203179    1% /run/user/1000

It freed about 54GB, 12613540 inodes. By calculation, about 4.49kb per file. They are all small cache files. You can check my blog’s speed. See if it is still good.

I check the W3 Total Cache page on the WordPress plugin directory. Some people have same issue just like me.

Then I dig it more. The developer of the W3Total has a post about it.

https://wordpress.org/support/topic/excessive-files-creation-issue/

 

David Yin

David is a blogger, geek, and web developer — founder of FreeInOutBoard.com. If you like his post, you can say thank you here

Leave a Reply

Your email address will not be published. Required fields are marked *