What is Inode?
It a record in hosting disk table that contains info about directory or file (owner, size, etc). So, the total number of files and directories equals to the number of Inodes.
Why Should We Reduce Inode Count in our Hosting?
Most hosting plans come with a limit of Inodes count. In other words, you may have to reduce the number of files and directories in your hosting if have too many files and directories/
Here is an easy way to reduce number of files if you use WordPress:
Did you know that when you upload a new media file, it usually creates about 10 different image files.
For example, if you upload an image file sunset.png, it will create:
- /wp_site_folder/wp-uploads/2018/09/19/sunset_50x50.png
- /wp_site_folder/wp-uploads/2018/09/19/sunset_150x150.png
- /wp_site_folder/wp-uploads/2018/09/19/sunset_250x250.png
- /wp_site_folder/wp-uploads/2018/09/19/sunset_350x350.png
- /wp_site_folder/wp-uploads/2018/09/19/sunset_550x550.png
- /wp_site_folder/wp-uploads/2018/09/19/sunset_650x650.png
- /wp_site_folder/wp-uploads/2018/09/19/sunset_800x800.png
- /wp_site_folder/wp-uploads/2018/09/19/sunset_900x900.png
- /wp_site_folder/wp-uploads/2018/09/19/sunset_1200x1200.png
- /wp_site_folder/wp-uploads/2018/09/19/sunset.png
It means that for every 1 uploaded image, WordPress will create 10 different files (same image resized to different resolution) which is 10 different Inodes.
So, if you upload 100 images, it will lead to 100 x 10 = 1000 Inodes.
Why it happens?
Every time there is a new image size defined (WP functions: add_image_size and set_post_thumbnail_size) in plugins and themes, it is how we ‘tell’ WordPress to resize every uploaded image and store a file into that resolution.
For example, if you install a Recent Posts with Thumbnails plugin, it make sense to store small images for recent posts thumbnails.
But if it is critical to reduce Inodes count, it can be done by reducing the number of Thumbnail images. Here is how it can be easily done (without any code change in plugins or theme):
1. Install and Activate ‘Stop Generating Image Sizes‘ Plugin
Source: https://wordpress.org/plugins/image-sizes/
Then:
- Navigate to Admin Panel -> Left Menu -> Image Sizes
- Click ‘Select All’
- Click ‘Save Changes’ button
It simply DISABLES all image size definitions defined into plugins and themes.
2. Install and Activate the ‘Force Regenerate Thumbnails’ plugin
Source: https://wordpress.org/plugins/force-regenerate-thumbnails/
Then:
- Navigate to Admin Panel -> Left Menu -> Tools -> Force Regenerate Thumbnails
- Click on ‘Regenerate All Thumbnails’ buttons and wait until it finish
Please Note: It’s a good idea to backup before you execute the above. Also, some themes generates their own image sizes and they may not display content properly after applying the above.
But if you use a WordPress theme by Tishonator.com, there is nothing to worry about 🙂 Our themes will work like a charm after applying the above optimization.
Thanks for this post! I was nearly the limit of my inode usage with my web host and wasn’t sure how to reduce my inodes. This reduced my inodes by a lot! Much appreciated!
This is great plugin combination for optimize wordpress images.Thanks a lot of.
finally successful
I got a 9.18% reduction in my inode count using the above. Thank you.
I still have 467,970 inodes though …