Inodes, speculated to be short for “index nodes,” have been around since the introduction of the first UNIX file system around the late 1970s.
They were adopted into Linux in the 90s—and for good reason. They’re an excellent way to keep track of how your files are stored, and the method many systems are still based on today.
What is an inode?
An inode is a file data structure that stores information about any Linux file except its name and data.
What are inodes used for?
Data is stored on your disk in the form of fixed-size blocks. If you save a file that exceeds a standard block, your computer will find the next available segment on which to store the rest of your file. Over time, that can get super confusing.
That’s where inodes come in. While they don’t contain any of the file’s actual data, it stores the file’s metadata, including all the storage blocks on which the file’s data can be found.
Information contained in an inode:
Device on which the file is stored
User and group IDs associated with the file
Permissions needed to access the file
Creation, read, and write timestamps
Location of the data (though not the filepath)
Inodes are also independent of filenames. That means you can copy a single file, rename it, and still have it point to the same inode as the original.
Where inodes can get weird
Much like your fixed-size blocks of data, inodes are also uniform. It is possible that you have a file that exceeds the size of your inode. In this case, your original inode will have to point to another inode in order to fully encompass the file’s metadata. This is called an indirect pointer.
On top of that, the number of inodes you have on your disk is static. That means if you have enough files, you may run out of inodes before you run out of disk space. If you run out of inodes, you’ll have to rebuild your filesystem and include a larger limit for inodes.
Handy inode commands on Linux
Use the command df-i to pull basic data about your inode usage, including the file system on which the inodes are stored, your total inode count, how many are in use (in count and %), and how many remain.