Home Blogging Blogging Tips How to reduce inode usage (files and folders) with a web hosting...

How to reduce inode usage (files and folders) with a web hosting limit

stress

If you are hosting your blog or website on a shared server (or I guess, any server), you may be hitting your inodes limit at some point. In a nutshell, it indicates the number of files and folders you are using (most likely you are hitting this inode usage limit because of the number of files you have).

You might be okay if you don’t have lots of files but for a site like Craving Tech where we do lots of reviews with many self-taken pictures, things can get gloomy fast after 5-10 years have passed.

Not to mention that WordPress (this blogging platform) and the theme you are using are creating their own image thumbnails PER image you are uploading.

For example, if you upload an image to a post, you might end up with 3-6 extra files. If a review post like this one has 22 images, you’d get 88 – 164 images in just a single post! Post daily and you’ll understand what’s coming. If you use Windows Live Writer, you might even get more files because its thumbnails will get even more thumbnails from WordPress + your theme.

And ever since WordPress 4.4, the team has also added an extra thumbnail generation of 768x pixels medium thumbnail per image upload to speed things up (responsive image).

When I migrated Craving Tech from HostGator to VentraIP Australia, I realised the blog had 165,000 inodes(!) and the migration could not proceed easily.

If you are hitting your inode limits on your host and cannot do a cPanel backup or is being forced to upgrade, you can always do a clean up. OR a prevention to stop this from happening in the future.

How to reduce inodes / files on your server

[1] Cut down the use of thumbnails on your site’s theme

Newsmag, the theme I’m using for Craving Tech is awesome and offers plenty of thumbnails generated options for different blocks and page styles. While it’s great, I didn’t realise I’d soon hit the limit and now I’m paying the price.

Newsmag thumbnail settings

If you are not there yet, I’d suggest to really bring down the number of thumbnails your site generates to a minimum. Sure, I had to let go of that funky Mega Menu and cool, big grids or post layouts with a mixed of thumbnail sizes, but I know I had to.

Since WordPress 4.4, you’ll get a new 728x thumbnail on every image uploaded to the server but it’s not available to be inserted in your post, unless you add these codes into your Child Theme’s functions.php (found the code here):

// Add 726x new thumbnail generated by WP 4.4 above, as an insert image option
add_filter( ‘image_size_names_choose’, ‘fresh_custom_sizes’ );

function fresh_custom_sizes( $sizes ) {
return array_merge( $sizes, array(
‘medium_large’ => __( ‘Medium Large’ ),
) );
}

[2] Disable WordPress auto thumbnails generation

WordPress also generates 3 thumbnails by default. You can change these settings through Settings->Media.

If you never use them on your posts and you don’t use the WordPress Gallery feature, I’d suggest turning them off. I set all their values to 0. BUT to be safe, have the “Thumbnail size” to default (150×150), rather than disable it compeltely – which I think will be used by WordPress as the default thumbnail featured image if your theme doesn’t have it.

It’s also used by many WordPress’ related posts plugins so it’ll be handy to have them around in case you need them one day.

WordPress Thumbnail Settings

[3] Remove old, unused thumbnails

If it’s too late (i.e you have reached your inodes usage limit on cPanel), you’ll unfortunately have to remove the unused thumbnails yourself. It’s the only, painful way.

I did this manually through an SSH terminal but I believe there are WordPress plugins that can help you out as well.

I prefer manual work because I don’t really trust these automated solutions which may remove things accidentally. BUT! If you remove the files manually from an SSH terminal, WordPress Media Library will still have links/references to these images unfortunately. So the best method is to actually use a plugin that remove database references AND the files together.

But I did end up removing the image files manually at the end.

Make sure to backup all your image galleries before doing this by zipping and downloading them. Your images and their thumbnails are inside the wp-content/uploads folder.

I used an SSH terminal to list the files based on the thumbnail sizes. Check out which ones you don’t use on your posts. Once you are positive, remove them with the rm -f command (remember having that backup?)

Remove-thumbnails-manually

If you are using Windows Live Writer and ever resize images in there, things get complicated. Windows Live Writer will create its own thumbnails of the resized images with _thumb.jpg. This thumbnail will then get auto-resized into more thumbnails, a complete mess!

And yes, you have to do this one by one or if you are a coder/scripter, you can create a script. I can’t be bothered so I did this manually as you see from the screenshots above.

Again, it is definitely best if you just use a well-known plugin to clean your Media Library up!

After removing these unused thumbnails, my inodes have gone down from 165,000 to 89,933 (that was over 70,000 thumbnail files/inodes removed)!

Related Posts at Craving Tech

The First 5 Things You Should Learn About SEO Note: This is a guest post written by Dayna Lutz Have you been looking to invest your money and time to improve your SEO ranking? You must have...
How to enable SSH on VaultPress (at HostGator or other web hosting) How to enable SSH on VaultPress - If you are blogging on WordPress, there is a higher chance of you backing up your WordPress blog through VaultPr...
6 Best Blogging Platforms Note: This is a guest post written by Blake Davis If you're looking to start your own blog, it can be difficult to determine which blogging pla...
What Type of Marketing is Best for Blogs? Note: This is a guest post written by Blake Davies In 2017 the blogosphere indeed seems like an incredible business idea. On the one hand, it all...
Custom Web Design vs Templates Note: This is a guest post written by Blake Davies After a while, your company’s website becomes obsolete and needs not only improvement but a ...