Say I want to observe how the flow from file name to cluster on hard disc goes.

I get the inode number of I file (which is mapped in a directory data):

1863 autorun.inf

So, now i know that i have to look for the inode numbered 1863 which will contain the pointers to the data on the hard disc.

Where is the inode data located and how does the os know where to find it?

  • Short ans:- An inode is a data structure on a traditional Unix-style file system such as UFS or ext3 and kernel access file by inode. – Rahul Patil Jan 18 '13 at 10:47
  • @RahulPatil Does that mean that they are never written on a disk? – TheMeaningfulEngineer Jan 18 '13 at 10:53
  • when you mount then it's load into the memory from disk – Rahul Patil Jan 18 '13 at 10:56
  • 1
    @Alan, they are certainly written to disk. The inode on disk is the file (it holds the permissions, owner, group, modification times, and other assorted information on the file). When the file is opened, it is loaded into memory for fast access, that is all. The filesystem reserves some space on disk to keep inodes (if you look at mke2fs(8), it says you can say how many to reserve). Exactly where they are placed, and their exact contents, depends on the filesystem. – vonbrand Jan 21 '13 at 18:40

Inode data are usually scattered around the disk (in order to cut down seeks). Being able to tell where the inode structures are is the core functionality of a filesystem driver - check LXR for current implementation of ext3 in Linux) or e2fsprogs sources if you are interested in details.

From a user's perspective you might want to take a look at dumpe2fs which will give you some information about a ext2-based (ext3/ext4) filesystem structure.

  • +1 for dumpe2fs. You can also play around interactively with debugfs instead. You can learn a lot playing with these tools. – psusi Jan 18 '13 at 14:19
  • 1
    Just be careful, one ill-advised write can destoy the filesystem. Better fool around with a throwaway filesystem created on a loopback. – vonbrand Jan 21 '13 at 18:41

The inode number points to an entry in the inode table on disk. This entry holds some information about the file, like file mode, uid/gid, number of links, ctime, mtime, atime and the disk block addresses, which may contain direct blocks, indirect blocks and double indirect blocks. See the following link for more information:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.