How To Increase Amount of Disk inodes in Linux

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, August 02, 2015

Follow me on Twitter as @mattiasgeniar

It doesn’t happen often, but at times you may run out of inodes on a Linux system.

To find your current inode usage, run df -i.

$ df -i
Filesystem                Inodes   IUsed     IFree  IUse%   Mounted on
/dev/mapper/centos-root 19374080   19374080  0      100%   /

Out of the available 19.374.080 inodes, none were free. This is pretty much the equivalent of a disk full, except it doesn’t show in terms of capacity but in terms of inodes.

If you’re confused on what an inode exactly is, Wikipedia has a good description.

In a Unix-style file system, an index node, informally referred to as an inode, is a data structure used to represent a filesystem object, which can be one of various things including a file or a directory. Each inode stores the attributes and disk block location(s) of the filesystem object’s data.

Wikipedia: inode

A disk with 0 available inodes is probably full of very small files, somewhere in a specific directory (applications, tmp-files, pid files, session files, …). Each file uses (at least) 1 inode. Many million files would use many million inodes.

If your disks’ inodes are full, how do you increase it? The tricky answer is, you probably can’t.

The amount of inodes available on a system is decided upon creation of the partition. For instance, a default partition of EXT3/EXT4 has a bytes-per-inode ratio of one inode every 16384 bytes (16 Kb).

A 10GB partition would have would have around 622.592 inodes. A 100GB partition has around 5.976.883,2 inodes (taking into account the reserved space for super-users/journalling).

Do you want to increase the amount of inodes? Either increase the capacity of the disk entirely (Guide: Increase A VMware Disk Size (VMDK) LVM), or re-format the disk using mkfs.ext4 -i to manually overwrite the bytes-per-inode ratio.

As usual, the Archwiki has a good explanation on why we don’t just make the default inode number 10x higher.

For partitions with size in the hundreds or thousands of GB and average file size in the megabyte range, this usually results in a much too large inode number because the number of files created never reaches the number of inodes.

This results in a waste of disk space, because all those unused inodes each take up 256 bytes on the filesystem (this is also set in /etc/mke2fs.conf but should not be changed). 256 * several millions = quite a few gigabytes wasted in unused inodes.

Archwiki: ext4

You may be able to create a new partition if you have spare disks/space in your LVM and chose a filesystem that’s better suited to handle many small files, like ReiserFS.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.