UNDERSTANDING INODES


As with most things system-related, things in the file-system are not stored by name, they are stored by number.Linux stores the data and information about each disk object (ex: file or directory) in a numbered data structure called an INODE number.

The Linux file system is based on inode entries.The inode holds the metadata about the files.

Whenever you create a new file kernel will generate one inode number(inum) for the file, the kernel uses that inode number to identify the file and to store the data in the inode table.

inode number also called as Index number

EACH INODE CONTAINS:

  • 1.File types(Executable, special file etc..)
  • 2.Permission(read,write,execute)
  • 3.UID(owner)-User identification number
  • 4.GID(group)-Group identification number
  • 5.File size
  • 6.Timestamp
  • 7.File deletion time
  • 8.Location of the file on the hard disk.
  • 9.Number of links(soft and hard)
  • 10.ACL(Access control List)
  • 11.Pointer to data

All the above information’s are stored in the inode.

Note: Inode doesn’t store the name of the file, The file name is stored separately along with the inode number

If the inode number is corrupted then the user cannot access that file, you might get the error message saying that “the file is missing or corrupted”

IMPORTANT: Understanding the concept of File-system 

Most of the file system diagram shows are a little bit confusing and take us to seriously misleading, So to make you understand the concept much better here I will explain you…

Name for inodes(Name for files,directories,devices,etc…) are stored on disks in directories,Only the names and the associated inode number are stored in the directory;the actual disk space for whatever the data is being named is stored in the inode, not in the directory;the names and numbers are kept in the directory;the names are not kept with the data

Let me show the simple structure of the file system :

In the file-system of-course, we are going to have the file name, the file name then link in to the inode; The inode link in to the physical data.

 

To view the inode number for a file:

#touch    /mydoc

#ls  -i   /mydoc  or  ls  -li  /mydoc

-i  ->inode

Is it possible to reuse the inode number?

You may have question pop-up on your mind while reading the above article, would it be possible to reuse the inode number for another file.

Yes, you can reuse it….

Once you remove a file from the directory that deleted file inode number will available for free; Next when you create a new file that free inode number will get assigned to the new file.

Let us see this with one example

#touch  /mydata

#ls  -i   /mydata

Now remove the file by using the “rm” command

#rm  -vf  /mydata

#ls  -l  /mydata

will get the error message saying no such file or directory

Now create another one new file

#touch  /backupfile

Now check the inode number

#ls  -i  /backupfile

the output You will get the previously deleted file inode number

Kindly Subscribe here👉🏿👉🏿 Click this link to Subscribe

 

 

http://www.linuxvasanth.com/delete-the-files/