The “inode” is sometimes referred to as an index node. But what is it? Basically, it is a file structure on a file system. More easily, it is a “database” of all file information except the file contents and the file name.
In a file system, inodes consist roughly of 1% of the total disk space, whether it is a whole storage unit (hard disk,thumb drive, etc.) or a partition on a storage unit. The inode space is used to “track” the files stored on the hard disk. The inode entries store metadata about each file, directory or object, but only points to these structures rather than storing the data. Each entry is 128 bytes in size. The metadata contained about each structure can include the following:
- Inode number
- Access Control List (ACL)
- Extended attribute
- Direct/indirect disk blocks
- Number of blocks
- File access, change and modification time
- File deletion time
- File generation number
- File size
- File type
- Group
- Number of links
- Owner
- Permissions
- Status flags
NOTE: the metadata does not include the file’s name.
Rather than the name, the inode of each file uses a pointer to point to the specific file, directory or object. The pointer is a unique number which usually is referred to as the inode number. For example, to get a listing of an inode number, use the following command:
$ ls –i filename
You can use the “stat” command to get more information than the inode number:
$ stat filename
A sample output is shown for both commands:
ls –i Journal.rtf buse@Buse-PC:/media/buse/Norton$ ls -i ./Journal.rtf 160 ./Journal.rtf
stat –i Journal.rtf buse@Buse-PC:/media/buse/Norton$ stat ./Journal.rtf File: ‘./Journal.rtf’ Size: 22661 Blocks: 48 IO Block: 4096 regular file Device: 811h/2065d Inode: 160 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ buse) Gid: ( 1000/ buse) Access: 2013-05-26 00:00:00.000000000 -0400 Modify: 2013-05-26 17:58:04.000000000 -0400 Change: 2013-05-26 17:58:02.180000000 -0400 Birth: -
In these cases, you can see that the inode number for the Journal.rtf file is 160 for both commands. An inode number can only change if the file is moved.
For example, the previous output came from the file Journal.rtf. If the file is moved to a different directory, the commands are executed again, the inode numbers are different:
ls –i Journal.rtf buse@Buse-PC:/media/buse/Norton/test$ ls -i ./Journal.rtf 372 ./Journal.rtf
stat –i Journal.rtf buse@Buse-PC:/media/buse/Norton/test$ stat ./Journal.rtf File: ‘./Journal.rtf’ Size: 22661 Blocks: 48 IO Block: 4096 regular file Device: 811h/2065d Inode: 372 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ buse) Gid: ( 1000/ buse) Access: 2013-05-26 00:00:00.000000000 -0400 Modify: 2013-05-26 17:58:04.000000000 -0400 Change: 2013-05-26 17:58:02.180000000 -0400 Birth: -
Now,