![]() |
![]() |
|
|
Understanding The Inode In Linux
By Joe Purcell Expert Author Article Date: 2011-08-08 Every day users would not have a clue as to what an inode is. However, when it comes to understanding data storage and use it is a core concept. Even those highly involved with data storage may not be extremely familiar with the topic. Let's take a look at what an inode is in Linux. The concept of the inode is simply a data structure that is found on unix file systems. It contains a file's metadata information such as:
There are a number of fun tools for understanding inodes. First is the `dumpe2fs` command which prints information about the ext file system: sudo dumpe2fs /dev/sda1 | grep -i superblock The superblock is kind of like the master inode. It has information on the file system such as type, size, status, etc. The above command prints out a number of superblock locations because the system keeps backups in case of failure. Second, the `ls` command can print the inode number for files: ls -i This can be useful when needing to reference a file by its inode location rather than file name. Similar to this is the `stat` command which displays the file's metadata. Here's an example: touch filename.txt stat filename.txt Perhaps the most revealing example of what inodes are is the `ln` command which links files. For example, a hard link of a file can be created as follows: touch file1 ln file1 file2 ls -i The above will output: 18351216 file1 18351216 file2 Notice that the two inumbers (inode numbers) are the same. Now, if we create a symbolic link: ln -s file1 file3 The output will show different numbers: 18351216 file1 18351217 file3 Hard links are treated as real files whereas symbolic links are treated as an abstracted form of the file. There are some limitations here. Hard links cannot link directories nor can they link to files on different file systems, whereas symbolic links can. There are reasons why hard links cannot link across file systems, but suffice it to say that it creates confusing references that the file system cannot handle. The Linux Magazine recently published on the inode and NixCraft has a great series of article on the unix file system and the inode. Both are more extensive than we will go into here and serve as great reference material. Understanding file systems on such an elemental level can greatly increase understanding of how to better manage file systems and why they work the way they do. About the Author: Joe Purcell is a technology virtuoso, cyberspace frontiersman, and connoisseur of Linux, Mac, and Windows alike. |
|
| Newsletter Archive | Article Archive | Submit Article | Advertising Information | About Us | Contact |
| StorageInsider is an iEntry, Inc. ® publication © All Rights Reserved Privacy Policy and Legal |