Understanding inode in Linux

I just wanted to keep myself acquainted with this inode.



What is inode?
In computing, an inode (index node) is a data structure found in many Unix file systems. Each inode stores all the information about a file system object (filedevice nodesocketpipe, etc.), except data content and file name. (from Wikipedia). 

From Cyberciti.biz,
An inode is a data structure on a traditional Unix-style file system such as UFS or ext3. An inode stores basic information about a regular file, directory, or other file system object.


So as what I understand, how does Linux stores the file and allocates a an index for its file system data structure  is thru index nodes (or inodes) (It's not clear if  i stands for index anyway, but it's easy if we term it i as "index"). 

inodes does not, "contain file names, only file metadata".

Unix directories are lists of association structures, each of which contains one filename and one inode number.

When searching for a filename, this means that, 
  • The file system driver must search a directory looking for a particular filename and then convert the filename to the correct corresponding inode number.

Additionally, The operating system kernel's in-memory representation of this data is called struct inode in Linux. Systems derived from BSD use the term vnode, with the v of vnode referring to the kernel's virtual file systemlayer.

For more info, read on WIkipedia (https://en.wikipedia.org/wiki/Inode).


From Cyberciti.biz, this is what an inode contains,
  • File type (executable, block special etc)
  • Permissions (read, write etc)
  • Owner
  • Group
  • File Size
  • File access, change and modification time (remember UNIX or Linux never stores file creation time, this is favorite question asked in UNIX/Linux sys admin job interview)
  • File deletion time
  • Number of links (soft/hard)
  • Extended attribute such as append only or no one can delete file including root user (immutability)
  • Access Control List (ACLs)

Remember that, each inode is identified by a unique inode number within the file system. Inode is also know as index number.


Commands that are helpful to bring the inode along with the filename are:

# ls -i filename
783365 -rw-r--r--. 1 geekgogie   geekgogie         165 Jul 18 07:20 stats


# find -inum 783365
./stats

Helpful urls:
http://www.linux-mag.com/id/8658/
http://en.wikipedia.org/wiki/Inode_pointer_structure
http://www.thegeekstuff.com/2012/01/linux-inodes/
http://www.linfo.org/inode.html


Comments

Popular posts from this blog

Converting sectors into MB - Useful in understanding the sectors in iostat in Linux

What is Disk Contention?

Installing MySQL from source: Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)