Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I know that the filename is stored in directories and not in inode. Kindly tell me where the inode number of a file is stored? Is it stored in the directory file?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Yes, directory entries contain the filenames and their inodes.

share|improve this answer
    
Thanks jlliagre. So when I give ls -il, the inode numbers are listed from the directory file right? –  LinuxPenseur Dec 15 '10 at 8:18
    
Indeed, that's where they live. –  jlliagre Dec 15 '10 at 9:17
    
Thanks, Only when i give ls -l can i see the inode number. Since directory is also a file, is there any way to see the contents of directory which will list the inode numbers also –  LinuxPenseur Dec 15 '10 at 10:24
    
Your statement "a directory is also a file" is dubious. A directory is a directory, not a regular file. Depending on the operation system and the filesystem used, you might or might not be able to see the raw content of the directory. You can try "od -c directory". –  jlliagre Dec 15 '10 at 10:37
    
@jlliagre, I am sorry, but i will have to disagree with you on your comment on ""a directory is also a file" is dubious". As far as my knowledge goes Directories: files that are lists of other files. So i guess Directory is also a file –  LinuxPenseur Dec 15 '10 at 10:51

Inode Structure image is provided below: ss of inode structure

See from the above image. The contents of directory contains inode numbers. Each inode is the index to the inode table. The inode table is stored in the logic disk block. Each entry of inode table stores some file attributes, such as file size, permission, ownership, disk block address, time of last modification etc.

Both directories and ordinary (non-directory) files are files. This definition could be found on Chapter 4, "Modern Operating system", Prof. Andrew S. Tanenbaum.

Further information on inodes can be found here: http://140.120.7.20/LinuxKernel/LinuxKernel/node17.html

share|improve this answer
    
Can you switch those links out with ones from a more permanent website? (i.e. something with a DNS entry) I was going to edit the image into your answer, but we try to avoid links that are likely to break within the year. –  Andrew B Apr 7 '13 at 4:15
    
@AndrewB I don't find a new link with a DNS entry for this web. Sorry for that. Thanks for adding the picture. :-) –  henry Apr 17 '13 at 13:51

According to me, INODE will also use a very tiny portion of disk space (1 or 2 sectors), depends on the size of a file information it holds. In Linux, Inodes will be created when we create the filesystem itself. During that time, a small portion of disk space will be taken for Inodes.

share|improve this answer
2  
"In Linux, Inodes will be created when we create the filesystem itself." - that depends on the filesystem. The traditional ext[234] filesystems do have fixed inode table, but for example ReiserFS and XFS has dynamic inodes. –  Janne Pikkarainen Jul 25 '11 at 10:32

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.