Too Many Inodes

I recently switched to Host Gator, and they have policy about the number of inodes.  I just noticed that my account moved to “Not Backed Up” just recently.  So, I thought I would blog a few of the things I learned while exploring…

Determining the Number of Inodes in a Directory

I found this command would do the trick:

[sourcecode language=”bash”]find . -printf "%i\n" | sort -u | wc -l[/sourcecode]

One of the advantages of Host Gator is that they provide SSH access.  I was able to login quickly and run the command in the different directories.  If you have a host that doesn’t offer SSH access, may I suggest PHP Shell?

Git Repositories

I had a rough guess that my git repositories might be part of the culprit.  If it’s based on the number of files, I guessed that git uses a bunch to track changes.  So, I did a little tinkering.

Sure enough, most of the inodes in my project are in the .git directory:

[sourcecode language=”bash”]

$ find . -printf "%i\n" | sort -u | wc -l
2050
$ find .git -printf "%i\n" | sort -u | wc -l
1195

[/sourcecode]

I found a few options to try.  First, I tried the fsck command, but that didn’t seem to make a difference in the inodes:

[sourcecode language=”bash”]

$ git fsck –full
Checking object directories: 100% (256/256), done.
dangling commit 9e18c6e42e3f62127776bdd2f52608f904991e08
$ find .git -printf "%i\n" | sort -u | wc -l
1195[/sourcecode]

Next, I tried the gc command, and that seemed to make all the difference in the world:

[sourcecode language=”bash”]# git gc –prune=today –aggressive
Counting objects: 912, done.
Delta compression using up to 16 threads.
Compressing objects: 100% (900/900), done.
Writing objects: 100% (912/912), done.
Total 912 (delta 525), reused 0 (delta 0)
$ find .git -printf "%i\n" | sort -u | wc -l
37[/sourcecode]

The repack didn’t do much:

[sourcecode language=”bash”]# git repack
Nothing new to pack.
$ find .git -printf "%i\n" | sort -u | wc -l
37[/sourcecode]

WordPress Cache

My next culprit is the WordPress Cache.  For example, on one of my blogs, the cache accounts for 76% of the inode count.

[sourcecode language=”bash”]

$ find . -printf "%i\n" | sort -u | wc -l
23323
$ find wp-content/cache/ -printf "%i\n" | sort -u | wc -l
17766[/sourcecode]

Well, that is another task for another day.  This is where I will start though.  If you have any ideas, please comment.

Resources

Leave a Comment

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