Technofunction

Concept of the i-Nodes and Superblocks in Linux/Unix System

The fundamental building block of  UNIX file systems (including Linux’s ext2/ext3) is the i-node. An i-node is a control structure that points either to the other i-nodes or to data blocks.

Creation of a file system is associated with creation of data structures which contains the information about the file. Each file is assigned a unique inode number or i-number. Every file in the system is identified with the corresponding inode number.

The control information in the i-node includes the file’s owner, permissions, size, time of last access, creation time, group ID, etc. ( the entire kernel data structure is available in /usr/src/linux/include/linux/ext3_fs.h—assuming, of course, that you have the source tree installed in the /usr/src directory). A typical allocation of space alloted to inode in a file system is about 1% of the total size.

Inode number can be found using:-

$ ls -i

$ ls -l

The one thing that an i-node doesn”t  keep is the file’s name.

While the directories themselves are special instances of  the files. And this means that each directory gets an i-node, and further the i-node points to data blocks containing information (filenames and i-nodes) about the files in the directory. The i-nodes are used to provide the  indirection so that more data blocks can be pointed to—which is reason why each i-node does notcontains the filename. (Only one i-node works as a representative for the entire file which contains the filename; thus it would be a waste of the space if every i-node contains the  filename information.) Each indirect block can be used to point in turn to other indirect blocks if necessary.

A kernel must search a directory looking for a particular filename and then convert the filename to corresponding inode number if file name is found.

Superblocks:-

The very first information which is read from a disk is its superblock. This small data structure reveals the several key pieces of the information, which includes the disk’s geometry, the amount of available space, and, most important of the all, the location of the first i-node. In the absence of a superblock, a file system is useless.

Something as important as the superblock cannot be left to the chance. Thus the Multiple copies of this data structure are scattered all over the disk to provide backup in case the one is damaged. Under the Linux’s ext2 file system, a superblock is placed after every group of blocks, which contains an i-nodes and data. One group consists of 8,192 blocks; thus this means the first redundant superblock is at 8193, the second at 16385, and so on.

Leave a Reply