Fundamentals 10 min read

Understanding Inodes: The Hidden Backbone of Unix/Linux Filesystems

An inode is a crucial Unix/Linux filesystem structure that stores file metadata, links files to data blocks, and enables features like hard and soft links; this guide explains its role, composition, related commands, and how inode exhaustion can affect system storage.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Understanding Inodes: The Hidden Backbone of Unix/Linux Filesystems

What is an inode?

An inode (index node) is a data structure used by Unix/Linux operating systems to store a file's metadata. It holds information such as size, ownership, permissions, timestamps, link count, and the locations of the file's data blocks. The file name itself is not stored in the inode.

Storage units: sectors and blocks

Hard‑disk storage is divided into the smallest addressable units called sectors , each typically 512 bytes. For efficiency the OS reads multiple contiguous sectors as a block , commonly 4 KB (eight sectors). Files are stored in blocks, while their metadata resides in inodes.

Metadata stored in an inode

File size in bytes

Owner user ID (UID)

Group ID (GID)

Permission bits (read, write, execute)

Three timestamps: ctime (inode change), mtime (content change), atime (last access)

Link count (number of directory entries pointing to the inode)

Pointers to the data blocks that contain the file’s contents

Viewing inode information

You can inspect an inode with the stat command, e.g. stat example.txt. The total number of inodes and their usage on each filesystem can be displayed with df -i. To see the size of each inode on a device, run sudo dumpe2fs -h /dev/hda | grep 'Inode size'.

Inode allocation and exhaustion

During filesystem creation the disk is split into a data area and an inode table. Each inode typically occupies 128 bytes or 256 bytes, and the number of inodes is fixed (e.g., one inode per 1 KB of disk). On a 1 GB disk with 128‑byte inodes and one inode per 1 KB, the inode table consumes about 128 MB (12.8 % of the disk). If all inodes are used (IUsed = 100 %), new files cannot be created even though free space remains.

Hard links and soft (symbolic) links

Multiple directory entries can point to the same inode; these are hard links . Create one with ln source target. The link count in the inode is incremented; when it drops to zero, the inode and its data blocks are reclaimed.

A soft link (symbolic link) is a special file whose contents store a pathname to another file. It is created with ln -s source target. Deleting the target leaves the symlink dangling, and the target’s inode link count is unaffected.

Practical troubleshooting example

On a low‑memory Linux server, a /data partition reported “disk full” despite 66 % free space. Checking df -i revealed inode exhaustion caused by a large number of tiny cache files in /data/cache. The solution was to delete some cache files and move the cache directory to a partition with free inodes using a symbolic link:

ln -s /opt/newcache /data/cache

Key takeaways

Inodes separate file names from file data, enabling features such as hard/soft links, efficient updates without restarting services, and flexible file management. Understanding inode structure, related commands, and how to diagnose inode exhaustion is essential for effective Unix/Linux system administration.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxUnixdisk-management
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.