Inode management tutorial

Inodes are an integral part of UNIX-like operating systems, as the ones used in the hosting industry and the one we use for our Shared Hosting Servers. To understand why there are limits on the number of Inodes you have at your disposal, you must understand what an Inode represents.

    Mode/permission
    Owner ID
    Group ID
    Size of file
    Number of hard links to the file
    Time last accessed
    Time last modified
    Time inode last modified

 

More cPanel tutorials:

How To Create, Edit, and Delete a File in CPanel Using File Manager

  I have a full backup of account through cPanel. How do I restore it?

Backup mysql database tutorial

Beginner Guide to cPanel Control Panel

Best practices for managing MySQL databases

CPanel Account Information Tutorial

CPanel Login Tutorial

CPanel Security

Cannot See My Website Online After Upload, Why?

Custom error page is not working

Default Home Directory Folders

Disk usage in cPanel

Getting Familiar With the cPanel User Environment

How Do I Create and Delete a Parked Domain

How do I create and remove an Addon Domain?


As you notice, the Inode does not contain information about the name or path of the file. This is stored in the directory itself as the directory is actually a table that contains the filenames in it as well as the inodes corresponding to them.

As the maximum number of inodes is set when the filesystem is created (configuring the shared server as part of the fleet for set datacenter location) and dedicated space is allocated for them you can run out of inodes before you run out of space for data which is why you have both Inode (File Usage) and Data (Disk Usage) in your cPanel which you can check on at all times. The number of Inodes available to you is in accordance with the other resources of your shared hosting plan.

Consider a Booster

While you may not be able to run a complex Magento based online shop with thousands of products on our starting plan, you will be able to do the same on the high-end Professional and Business Pro plan as it offers more Inodes and also more CPU, RAM, etc, which are essential to running such a store.

In the following tutorials, we will also take a look at the process of checking your Inodes, using our dedicated Inode cPanel tool in order to keep your hosting account healthy, common Inode generators, how to maintain them and overall best practices regarding Inodes.

 

More cPanel tutorials:

How to Backup My Website in cPanel

How to Create a MySQL Database, a User and Delete Database in Cpanel

How to Create a SubDomain in Cpanel

How to Create a Website/Domain Redirect in cPanel

How to Reset or Change to a New CPanel Password

How to Set Up and Delete a Cron Job

How to Setup Google Apps MX, CNAME and SPF records

How to Use the Hosting Features in cPanel control Panel

How to access raw log files

How to check your PHP version and configure your PHP settings

How to force your website url with www or non-www using htaccess

How to optimize your website to use less server resources

How to upload files to a website

 

How to see the Inode Usage via cPanel

With cPanel being limited to only showing the number of Inodes without any additional information about this resource, we took it upon ourselves to create a tool which will be easy to use by our users and show them the exact number of Inodes per folder for every folder in their hosting plan. We integrated this tool in cPanel, and you can easily find it at the top of the page listed under the Files section.

Once in your cPanel, click on the Inode icon.

Take into consideration that the tool might be loading slower in case you are at the limit of your Inodes. Once it loads, you will have a list of all folders in your hosting account and their respective Inode count.

As per the instructions located in the tool's description, when you want to clean Inodes from a certain folder just scroll-click on the folder, and it will be opened in cPanel's File Manager in a new tab on your browser.

Warning

If you see a home/user/mail folder make sure you have checked your mails via a mail service first before deleting those files.

There you can remove the files (selecting multiple files with ctr or shift is possible in the Fille Manager), but note that if you just delete them, they will be moved to the trash of the File Manager from where they can be recovered in the next 24 hours. If you want to see immediate results tick the Skip trash button box and the files will be removed completely. Once you are ready, return to the tab of the tool and refresh it to see the information update.

More cPanel tutorials:

Most common Inode over usage solutions

If you see a home/user/mail folder make sure you have checked your mails via a mail service first before deleting those files.

There you can remove the files (selecting multiple files with ctr or shift is possible in the Fille Manager), but note that if you just delete them, they will be moved to the trash of the File Manager from where they can be recovered in the next 24 hours. If you want to see immediate results tick the Skip trash button box and the files will be removed completely. Once you are ready, return to the tab of the tool and refresh it to see the information update.
Quick access to the application which you use:

    Magento
    PrestaShop
    Drupal
    Joomla
    WordPress


Magento

Both Magento 1.x and 2.x can generate massive amounts of inodes when left unattended for long periods of time. In 1.x you have a greater variety of file generating processes which are not tied to the cache and thus have to be removed separately.

Cache - The cache and sessions files are the ones you should be careful with. Considering you will have to purge the cache every time you make a change in your products selection, regularly cleaning the cache folders is just one of those things, shop owners must do. Large product catalog stores can contain a lot of cache, and even some for images of long ago removed products.

To secure your data, create and download a Database backup of your store. Then navigate to the admin area and go to the System → Cache Management section to click the Clear the Magento Cache and Flush Catalog Images Cache buttons.

Temporary files - You can safely remove all temporary files which are still stored in the var/tmp folder

Old imports - Importing data always leaves a trace when it comes to hosting that same data. We suggest you check your var/import folder for older imports which can consist of products, customers, and even extensions.

Sessions - The session files for Magento are generated inside the public_html/var/sessions. By deleting all files outside the range of the last few days (or last session), you will have one less probable troublemaker to worry about. To remove old sessions via SSH, you can type:

find /path/to/magento/var/session -name 'sess_*' -type f -mtime +7 -exec rm {} \;

as the number can be changed depending on the number of days you may want to keep the last few days or only the last day worth of sessions

Reports - Check and clean your Magento reports in var/report. While it is advisable to check on your reports and fix the issues of your website in their core, to just stop the application from creating additional reports you will have to navigate to the reports.php file and find the following function which is called in the process of creating a report:

public function saveReport($reportData)
{
$this→reportData = $reportData;
$this→reportId = abs(intval(microtime(true) * rand(100, 1000)));
$this→_reportFile = $this→_reportDir . '/' . $this→reportId;
//...snip...
@file_put_contents($this→_reportFile, serialize($reportData));
//...snip...
}

Now comment the following line and you are done:

#@file_put_contents($this→_reportFile, serialize($reportData));

Logs - While your Magento website might be running smoothly, there is still a log being generated every time something "moves". Over time this will accumulate to a lot of bloat in your var/log folder. Remove the excessive files, but not before inspecting them for actual issues already logged by Magento. To remove the log files, go to System → Configuration → Advanced → System → Log Cleaning

PrestaShop

One of the most common issues with PrestaShop is that its caching system works very badly optimized. The infamous cachefs folder will grow substantially in size over time due to files being cached as new instances every time instead of the old entries of the file being removed/overwritten once a change of the file has been made. This calls for action which can be either cleaning the cache or temporarily disabling the caching option. The second variant works well if you make changes to your shop on certain intervals, so you can make the change, enable cashing and then before the next change disable it again while cleaning the old instances of your products cache.

Clear Cache - Sometimes you may need to clear the cache without accessing Back Office. By using your favorite FTP client or your cPanel's file manager access the folder of your PrestaShop instance and delete everything except the index.php files in the following directories:

/cache/smarty/compile/
/cache/smarty/cache/
/cache/cachefs/
/img/tmp/
/themes/your_theme/cache/

To clear the cache of your classes and controllers, remove the /cache/class_index.php file. This is the only core index.php file you can safely remove without risking issues with your website.

Disable Caching - In contrast with the cleaning cache procedure, to disable caching altogether, you will need administrative access to the Back Office of your PrestaShop. Access the Advanced Parameters → Performance section which is identically placed for both version 1.6 and 1.7.

After that you will have to turn the Template compilation: Force compilation setting on and then mark the Cache option with a No. Now you can turn off the Use Caching option as well as all options in the Combine, Compress, and Cache section. Save the changes and you are done.

Drupal

In the case of Drupal, you'll find a large number of files inside the cache folder of public_html/cache. We recommend clearing it approximately every month (you can create a cron for it).

Joomla

Like Drupal, the typical location for a large number of files is the public_html/cache folder that should be cleared on a regular basis. You can create a cron for this as well.

WordPress

Thumbnails - The thing that many people miss is that Wordpress doesn't just upload one version of each image. Depending on the theme or different plugins installed, you could have a dozen or more images being created for every image you upload. So if an image gallery plugin tells WordPress, it needs five different sizes (to use in different gallery layouts, for example), and a theme has 4 different thumbnail sizes it needs for different layouts, and Wordpress itself needs a small, medium and large, it can really add up.

So you need to look in your images directory, and you will be able to see how many image copies are created by each plugin. If there are a lot, you may need to check the plugin that is creating them, and re-configure it. Or you can also disable a certain size in your functions.php file. To do this, log in to your WordPress Dashboard and navigate to Appearance → Editor. You will see a warning which you should read and follow as modifying these files can seriously damage your WordPress install and as such a child theme use is strongly recommended.

Next, you will have to find your current theme's function.php file and click on it. Then search for:

add_image_size and set_post_thumbnail_size

If you get a result, it means that your theme is generating thumbnails in certain sizes. If you are sure you don't need this extra thumbnail generation, remove the selected code and click on Update File.

Once you have properly disabled the different sizes, that won't delete all the previously uploaded variations. You will need a plugin like Force Regenerate Thumbnails, which will delete all current thumbnails/image sizes and recreate them based on your new settings. Addressing this across your whole Wordpress media library can clear up a lot of inodes if you are running an image site. It may not be your only problem, but definitely somewhere to look. One more thing to note is that you should not go deleting the images through FTP or the cPanel's file manager. Only do it through WordPress itself or the WordPress database won't know they are gone. WP references every image in the database which may lead to unwanted results if the actual images are removed.

Inactive themes and plugins - Plugins and themes, especially paid and more complex ones tend to bloat WordPress installations. Not only with their initial size but also with every update and sometimes extra data that is generated like cache and log files. Removing resources which you don't actively use is a great way to lower your Inodes and if you ever need a certain theme or plugin, you can easily re-install and re-activate them.

Optimization plugins - While optimization plugins like W3 Total Cache and WP Rocket can increase your WordPress based website's speed, at the same time, they will create a lot of Inodes while running their caching processes. Plugins like WP-Rocket - one of the most used optimization plugins for WordPress have an easy to navigate UI and provide clear/purge cache features with a single button click. Alternatively, you can flush your WordPress based website's cache by using SSH and a WP-CLI command.

Navigate to the directory of your WordPress install and execute:

wp cache flush

After that you will see the confirming message:

Success: The cache was flushed.

Those are the most common high Inode usage cases we have seen from the most popular apps. If you still have a high Inode count even after cleaning your Magento or WordPress, we suggest you use our Inode Usage tool in your cPanel for further information on where in your hosting account are such removable files situated.


Best Practices


In the last tutorial of these series, we provided you with the most common problems with different applications and their solutions in regards to the Inode count on your account. In this tutorial, we will be providing you with the best ways to avoid an exponential and unwanted increase in your Inode counts while maintaining your account healthy will also impact other resources like Disk Usage and Bandwidth as these three resources are inherently connected.

    Emails - Again, we are seeing that older emails, spam, and even full email trash are the most common culprits in yet another resource over usage. While we already have a dedicated email section for dealing with emails in which you can check how to perform export, cleaning, trash empty schedule and applying spam filters to reduce the amount of spam you receive, here we will still mention those methods as a viable option when cleaning Inodes. As each mail is a separate Inode having multiple mailboxes full of spam is the quickest way to get to a critical amount of Inodes quickly.

    Backups - We completely agree with production environments being backed up on a regular basis. However, when you start forgetting to clean your older obsolete backups which are just laying around your /public_html folder, you are missing out on potential Inodes being freed for other uses. Make sure that you have a local copy of everything important in your hosting account and then remove these older backups via an FTP client or cPanel's File Manager.

    Dev/Test Environments - Developing and testing new features for your website is a great way of increasing your visits and growing a successful business. Most of the time this requires full copies of your live environment, so we are talking about entire websites being duplicated here. Having a separate Magento store on top of your existing one is such a case. If a constant dev environment is required, customers should consider higher plans with more Inodes like our VPS and DS solutions. If you only need a temporary testing playground, you can always make one as long as you are in your Inode limit, but erasing it after the task has been completed will assure you have enough Inodes for your hosting account's smooth operation in the future.

    Large Cache Folders - Caching is very important for a speedy delivery and user retention. But as with many good things, there are a few cons to consider, one of which is the immense volume of files is created when caching is enabled. Especially if we are talking about non-incremental caching which creates additional instances of the changed files each time they are modified as we have seen in some applications.

    cPanel's Default Email Account - We decided to separate this from the first point of this tutorial to distinguish that this email's creation is not a user choice. However, there is still a need for maintaining it even if you almost never receive actual useful information in your default account. Misdirected spam and Cron job notifications will often plague this account to the point of being time-consuming to remove all of the emails there. We recommend removing these emails via Webmail service. However, you can also use FTP/File Manager as long as you are careful in what you remove. This email account is located in the home/user/mail folder of your account. There will be two folders called new and cur.

Warning

It is very important that you do not remove the folders themselves and only delete the files inside due to the recreation process for these folders which can partially corrupt your hosting account environment.

    Cron Jobs - Cron Jobs are used to schedule an action (output, call, or script execution). The schedule can be done on an interval by the minute, hour, day, month and exact weekday. They are very useful and can be seen being generated in the cPanel Cron Job section by applications such as Magento, OpenCart, and Drupal. Cron Jobs can also be configured manually, but with their great utility comes a few possible hurdles which affect your Inodes. Firstly, the output of a successfully executed cron job is sent via email to your default mail account. To avoid that you can add one of the following strings at the end of your command:

    &> /dev/null

    or

    >/dev/null 2>&1

    The first will redirect the standard command output to the null device, which is a specifically made to discards the information which is sent to it, while the second will redirect the standard error stream to the standard output stream which prevents any output from the command being available.

    Secondly, most commands utilize wget and curl which create a file with the output of the command in the home folder of your hosting account. Considering that Cron jobs can be run every few minutes, the number of files with output can flood your account fast. For example, if you have the following wget command:

    5 * * * wget -O /dev/null -o /dev/null example.com

    The -O will send the downloaded file to /dev/null, and the -o will send the logs to /dev/null.

    A similar result can be achieved with:

    5 * * * wget -O - mysite.com > /dev/null 2>&1

    For curl you can take a look at the following example:

    1 1 * * 0 /usr/bin/curl --silent http://example.com/some.php &>/dev/null

    If you still see a high amount of Inodes, you should check our Inode Usage tool in your cPanel and locate the Inode cluster, causing the issue. If there are no other files, which you can backup and remove, consider an upgrade as the shared hosting environment is limiting the growth of your website and business. Our VPS and Dedicated Server plans are just one click away in situations like that.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

I have a full backup of account through cPanel. How do I restore it?

It is recommended that you maintain healthy backup of your website and possibly download the...

How To Create, Edit, and Delete a File in CPanel Using File Manager

This tutorial will be useful for you to understand how to create a file, edit a file or delete...

How to Create and Manage a MySQL Database

Create MySQL Database and User via cPanel The MySQL Database Wizard is another useful tool...

How do I create and remove an Addon Domain?

An add-on domain is a separate domain name that you add to your web hosting subscription with...

How to Set Up and Delete a Cron Job

A cron job allows you to run a certain command at times set by the job. For example, you could...