The understanding and supplement of the Inode

Source: Internet
Author: User

The inode is always so mengmengdongdong for those who are just beginning to learn Linux. This article is mainly to share my understanding of the inode, as well as in practice, encountered a small problem with the inode number.

First, what is the Inode

Inode refers to a data structure in many "Unix-like file systems". Each inode holds meta-information data for a file system object (including files, directories, device files, sockets, pipelines, and so on) in the file system, but does not include data content or file names-Wikipedia.

In Linux, there is an important philosophy is "all Files", and a file is to be saved on disk, more intuitively, such as a text file, in the GUI we have to double-click to open it, under the CLI we need to use cat and other commands to view it, but we see it is its content, Where is its own property information stored? Yes, it's in the inode.

This has to do with the partition of the disk, when we get a new hard drive we usually have to format before we can use it, what is "formatting"? Popular point is to put a disk on a small lattice, similar to the lattice-like stationery. There are two major "big squares": One called the metadata area and the other called the data store. The data store is where the data is stored, what is metadata? In fact, it is a file inode number, permissions, belong to the main group, size, timestamp, the disk block of the file, extended properties and so on, but remember that there is no file name in the Inode. We use stat filename to view the metadata of a file.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5B/F7/wKiom1UXubqz9lqAAAENIdyxvzE940.jpg "title=" [w]1i[ Ii{mwz3$itgemrh1a.png "alt=" Wkiom1uxubqz9lqaaaenidyxvze940.jpg "/>

Second, why should have the Inode

For a computer, it is easier to memorize a file than to use the text, so the computer is to rely on the inode number to identify each file, the same file system Inode number is the only OK, so you can only determine a file.

Third, the file name of the storage

We just said that there is nothing in the inode and there is no file name, where is the filename exactly? is in the directory. Linux is all files, directories are also files (in fact, Windows folder is also a file). The structure of a catalog file is a list of a series of catalog items. Each directory entry consists of two parts: the name of the containing file or directory, and the inode number that corresponds to the file or directory name. Creating a directory requires a three-step process:

1. Add an entry in the parent directory file;

2, allocate an inode;

3. Allocate a storage block to save the files and subdirectories that are currently being created by the directory.

An entry for two subdirectories is automatically generated in the created catalog file, with the name: "." and ".". The former has the same inode number as the directory and is therefore a "hard link" to the directory. The inode number of the latter is the inode number of the parent directory of the directory. Therefore, the total number of "hard links" in any directory is always equal to the total number of subdirectories (including hidden directories) plus 2. That is, ".." In each "subdirectory file" Entry, plus the "." In its own "catalog file". Entries, plus the entries in the "Parent directory file" to the should directory.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5B/F1/wKioL1UXwWai4MRcAAOLlGfqGtg763.jpg "title=" @NI] (A ) (' {OGD9 ' c3g%hehx.png "alt=" Wkiol1uxwwai4mrcaaollgfqgtg763.jpg "/>


This/All files are directories, the number of hard links visible/24,/the next 22 directories, as for the Wc-l 23 is because there is a row of total.

Iv. sharing a small problem of discovery

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5B/F1/wKioL1UXwkmAJhT1AAOInTaoStk796.jpg "title=" mwcg0m ' Sr[u7mm{6m{smzta.png ' alt= "wkiol1uxwkmajht1aaointaostk796.jpg"/>


We found that there are several directories in the inode number is the same, such as USR, Var, boot, we do not say that the inode number is the unique identification of computer recognition files, the same inode number means that these directories are the same file? The answer is no, they are not the same file. Because the inode only corresponds to a file or directory condition is: on the "Same file system", the different partitions are different file system (it is said that LVM can be divided into the same partition different file system, but this is something), Therefore, different file system can exist in the same number of inode, so they are a few different files. Directories with the same inode number are partitioned in separate file systems.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5B/F1/wKioL1UXxfayQdgRAAFPb7s2vU0952.jpg "title=" {)]ksj ]m_[jje ' ~a7k4}0iy.png "alt=" Wkiol1uxxfayqdgraafpb7s2vu0952.jpg "/>

Well hope this article can bring you the help, please crossing this article of the wrong place, humbly!

PS: Today read an article about the AIIB, feeling that the establishment of AIIB only a point: the World Hee-hee, all for the benefit of the world're awfully, all for the benefit.


This article is from the "Linuxlove" blog, make sure to keep this source http://linuxlover.blog.51cto.com/2470728/1626208

The understanding and supplement of the Inode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.