Table of contents
1.
Introduction
2.
Inode
3.
The Inode Structure
3.1.
Applications
3.2.
Disadvantages
4.
Frequently Asked Questions
4.1.
What are inodes used for?
4.2.
What happens to the inode when the file is deleted??
4.3.
Can you run out of inodes?
5.
Conclusion
Last Updated: Mar 27, 2024

Inode

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?
Operating Systems

Introduction

In UNIX operating systems, an inode is a data structure that stores important information about files in a file system. When a file system is formed in UNIX, a certain number of inodes are also created. The inode table typically takes up roughly 1% of the entire file system disc space. Sometimes, people interchange the words inode and inumber. The terms are similar and correlate, but they do not refer to the same item. The term inode refers to the data structure; the inumber is the inode's identification number. The inumber is merely one significant piece of data in a file. 

Also read, Multiprogramming vs Multitasking And Open Source Operating System

Inode

In a Unix-style file system, an inode (index node) is a data structure that refers to a file-system object such as a file or directory. Each inode maintains the object's data properties and disc block addresses. Metadata (times of last change, access, and modification), as well as owner and permission info, can be found in file-system object attributes. 

A directory is a collection of inodes with their assigned names. The list comprises entries for itself, its parent, and each of its children.

A file is assigned a name and an inode number, a unique integer within the file system when created. The file names and inode numbers are saved as entries in the directory that appears to the user to contain the files. In other words, the directory connects file names to inodes.

When a user or a program refers to a file by name, the Operating System looks up the matching inode, which allows the system to gather the information it requires about the file to execute subsequent activities.

In other words, a file name is simply an entry in a table of inode numbers in a Unix-like operating system rather than being directly associated with a file. The inode numbers and their associated inodes are recorded in inode tables, strategically placed throughout a file system, especially near the beginning.

The concept of inodes is very significant for recovering damaged file systems. When bits of an inode is lost, they appear in the lost+found directory of the partition where they were previously located.

Also read, Process Control Block in OS

The Inode Structure

The inode structure is pretty simple for seasoned UNIX developers or administrators, but there may be some interesting facts about the insides of the inode that you don't already know. The following definitions illustrate some of the critical information included in the inode that UNIX users rely on daily:

  • Inode number
  • Mode information to discern file type and also for the stat C function
  • Number of links to the file
  • UID of the owner
  • Group ID (GID) of the owner
  • Size of the file
  • The actual number of blocks that the file uses
  • Time last modified
  • Time last accessed
  • Time last changed

The inode holds all information about a file not contained in the file's name or data content.

Applications

  • The concept of inodes is very significant for recovering damaged file systems. When parts of an inode are lost, they appear in the lost+found directory of the partition where they were previously located.
  • The inode holds all of the administrative information required to read a file. The metadata for each file is kept in inodes in a table structure.

Disadvantages

  • Since inode information is maintained separate from data, data access sometimes necessitates a lengthy search when the file is first opened.
  • When scanning directories, inodes of files in a shared directory are not maintained together, resulting in poor performance.

    You can also read about the Multilevel Queue Scheduling.

Must Read Evolution of Operating System

Frequently Asked Questions

What are inodes used for?

The inode is a Linux (and other Unix-like) data structure used to store information about your server's files, directories, emails, code, and anything else. The number of inodes is proportional to the number of files and folders.

What happens to the inode when the file is deleted??

The inode and data blocks are marked as unused so that this inode number and data blocks can be reused. As a result, you may quickly retrieve the data using only the inode structure's information.

Can you run out of inodes?

A file system's inode count is fixed; it can run out of inodes without running out of disc space. (For example, a 1GB disc with a million empty files.) Running out of inodes can be problematic because the errors all imply that disc space is a problem — even if you have plenty of disc space available.

Conclusion

An inode (index node) refers to a file-system object, such as a file or directory, referred to by an inode (index node). Each inode maintains the object's data attributes and disc block addresses. File-system object properties contain metadata (last change, access, and modification timings), as well as owner and permission information. We learned about Inode and its application in this blog and how inode is used to store information about your server's files, directories, emails, code, and anything else.

Recommended Reading:

Do check out The Interview guide for Product Based Companies as well as some of the Popular Interview Problems from Top companies like Amazon, Adobe, Google, Uber, Microsoft, etc. on Coding Ninjas Studio.

Also check out some of the Guided Paths on topics such as Data Structure and Algorithms, Competitive Programming, Operating Systems, Computer Networks, DBMS, System Design, etc. as well as some Contests, Test Series, Interview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.

Cheers!

Live masterclass