Inode and Inumber

An inode is a data structure that contains important information regarding file within a file system. Whenever file system is created in UNIX, a set amount of inode is created. Usually, about 1% of the total file system disk space is allocated to the inode table.

Inode and Inumber (or Inode Number):

Inode and Inumber seems to be same, but they are not. Inode refers to the data structure and the inumber refers to the identification number of the inode. So, inumber is also referred to as inode number. The inode table contains a listing of all inode numbers for the respective file system. When users search for or access a file, the UNIX system searches through the inode table for the correct inode number. When the inode number is found, the command in question can access the inode and make the appropriate changes if applicable.

Take, for example, editing a file with vi. When you type vi , the inode number is found in the inode table, allowing you to open the inode. Some attributes are changed during the edit session of vi, and when you have finished and typed :wq, the inode is closed and released. This way, if two users were to try to edit the same file, the inode would already have been assigned to another user ID (UID) in the edit session, and the second editor would have to wait for the inode to be released.

How to check the inode number for any file?

[soj@centos ~]$ ls -i firewall.txt
458778 firewall.txt

[soj@centos ~]$ stat firewall.txt
File: `firewall.txt’
Size: 426 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 458778 Links: 1
Access: (0644/-rw-r–r–) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2012-01-23 08:36:57.000000000 -0800
Modify: 2012-01-23 08:36:52.000000000 -0800
Change: 2012-01-23 08:36:52.000000000 -0800

The inode contains all the information about a file except it’s actual file name and the file contents.
The following definitions provide just some of the important information contained in the inode that UNIX users employ constantly:

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
Actual number of blocks that the file uses
Time last modified
Time last accessed
Time last changed

The information listed above is important to files and is used heavily in UNIX. Without this information, a file would appear corrupt and unusable. In UNIX, directories are actually files that have a few additional settings in their inodes. A directory is basically a file containing other files. Also, the mode information has flags set to inform the system that the file is actually a directory.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s