Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
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? –  Alan 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
add comment

2 Answers

up vote 4 down vote accepted

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.

share|improve this answer
    
+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
add comment

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:

http://140.120.7.20/LinuxKernel/LinuxKernel/node17.html
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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