Wednesday, June 30, 2010

The attack of the inodes – how to find out your number

SkyHi @ Wednesday, June 30, 2010

“Inode” is a term used in Linux/UNIX file systems. Each file, directory, symlink… is represented by an inode which has a bunch of information on the file or directory (check out Understanding UNIX / Linux filesystem Inodes for more information). Computers running Linux have a maximum number of inodes allowed, i.e. a maximum number of files and directories, independently of their sizes. This number is quite big so in general it won’t affect you. Furthermore, if you are running Windows you might be tempted to skip this post altogether. But if you have a domain in a hosting service and your web hosting package is in a Linux server, you should definitely continue reading. In my previous post Hostgator pros and cons, I explained how it has a maximum of 50,000 inodes quota and how it’s not that difficult to reach that number. Whether you are using Hostgator as your web hosting provider or any other, you should know about inodes and how their shortage can become a problem. In this post I will go through ways to find out how many inodes do you have. In the 2nd part, I am going to compile a list of the number of inodes different packages have when you install them (important if you want to run WordPress, TYPO3, Mambo, TikiWiki…).

To find out how many inodes are there in a folder or web hosting account, there are three ways. Whether one or another are possible, or all three, will depend on your web hosting provider.

Option 1. Submit a ticket

This one is easy and only takes as long as your provider’s support takes. Just ask them for an inode report on your account. Hostgator complied within 4 hours, and that was for three different accounts.

Advantage of this method: little effort and you don’t have to learn any commands.

Disadvantage of this method: if you haven’t been warned of being above the inode limit, you might be calling their attention to your account unnecessarily. Furthermore, you depend on others to know the number of inodes.

Option 2. Via ssh

If your provider allows you to ssh to your account, then once you are connected, all you have to do is type the following:

find . -printf "%i\n" | sort -u | wc -l

Advantage: quick (it can take 20 seconds to count 10,000 inodes).

Disadvantage: not all web hosting providers allow you ssh access. In Hostgator, for example, you can ask for ssh access but you need to give them a copy of your photo id.

Option 3. Via ftp

This can’t be done using FileZilla or similar. From a Linux machine you must open a terminal and:

  1. First make sure you have the curlftpfs package installed. Depending on your Linux distribution it can be as simple as running (as super-user)

    yum install curlftpfs

  2. Then you have to create the directory where you want to mount the ftp connection to your hosting account.

    mkdir ftp-domain-folder

    where ftp-domain-folder is the name of the directory you chose.

  3. After that you connect to your account.

    curlftpfs -o user=xxxx:yyyy ftp://domain-name.zzz/ ftp-domain-folder/

    where xxxx = user name and yyyy = password.

  4. And you run this command to count the inodes.

    find ftp-domain-folder/ | sort -u | wc -l

  5. Finally, unmount the folder (requires super-user priviledges):

    umount ftp-domain-folder/

Advantage: you can do it from your computer, quite easy, no need for ssh,…

Disadvantage: it takes quite a bit (over an hour to count 10,000 inodes) and you need to run the commands from a Linux computer.

To check the total number of inodes, if you don’t have ssh access, I would suggest using option 1. Once you know the total number, you can use option 3 to find out the inode count in folders within your hosting account. Each individual folder will not have as many inodes as the whole account so the command will take less time. For example:

find ftp-domain-folder/mail/ | sort -u | wc -l

where mail is the folder where all your email accounts and emails are, or:

find ftp-domain-folder/public_html/folder-name/ | sort -u | wc -l

to check the inodes inside a folder in your account. This way you can check if you have erased enough files if you were reaching the limit.