the inode of the Linux file system
index node Inode: What is actually stored is some information about the actual data called "metadata" (that is, the description of the file attributes). For example: File size, device identifier, user identifier, user group identifier, file mode, extended attributes, file read or modified timestamp, number of links, pointers to disk chunks that store the content, file classification, and so on.
(Note data partitioning: Meta data + data itself)
Also note : There are two types of inode, one is the inode of the VFS, and one is the inode of the specific file system. The former is in memory and the latter is on disk. So each time the inode redeployment in the disk is populated with the inode in memory, this is the use of the disk file Inode.
Notice how the Inode is generated : the size of each inode node, typically 128 bytes or 256 bytes. The total number of inode nodes, given at the time of formatting (modern OS can dynamically change), usually set an inode every 2KB. The general file system rarely has less than 2KB of files, so the reservation in accordance with the 2KB, the general inode is not finished. Therefore, the inode will have a default number when the file system is installed, and the latter will change according to the actual needs.
Note inode number : The inode number is unique and represents a different file. In fact, in the internal Linux, access to files are through the inode number, the so-called file name is only easy for users to use. When we open a file, first, the system finds the inode number corresponding to the file name, and then, through the inode number, the inode information, and finally, the inode to find the file data block, can now process the file data.
inode and file Relationships : When a file is created, an inode is assigned to the file. An inode only corresponds to one actual file, and one file will have only one inode. The maximum number of inodes is the maximum number of files.
Wikipedia, the free encyclopedia
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 name .
UNIX pioneer Dennis Ritchie says ,inode This named source may be the file system's storage organization as a flat array, and hierarchical directory information uses a number as the index value for the flat array of file systems (index).
When the file system is created (formatted), the storage area is divided into two contiguous storage areas. A meta-information data that is used to hold file system objects, which is a table of inode, with each inode being 256 bytes or 128 bytes by default. Another content data used to hold "File system objects", divided into 512-byte sectors, and blocks of 4K bytes made up of 8 sectors. Blocks are the basic unit of reading and writing. The total number of inode for a file system is fixed. This limits the total number of file system objects that the file system can store. Typically, all inode takes up about 1% of the file system's storage capacity.
Each "File system object" in the file system corresponds to an "inode" data and is identified by an integer value. This integer is often referred to as the inode number ("I-number" or "inode numbers"). Because the file system's Inode table is stored and the total number of entries is fixed, the inode number can be used to index the Inode table.
The Inode stores some meta information for the file system object, such as the owner, access rights (read, write, execute), type (file or directory), content modification time, inode modification time, last access time, address of the corresponding file system storage block, and so on. Knowing the inode number of 1 files, you can isolate the storage address of the file content data in the inode metadata.
The file name and directory name are the easy-to-use aliases for the FileSystem object. A file system object can have multiple aliases, but there can be only one inode, and this inode is used to index the location where the file system objects are stored.
- The inode does not contain a string of file or directory names, and contains only the meta information for the file or directory.
- The Unix File system directory is also a file. Opening the directory is essentially reading the "catalog file". The structure of the catalog file is a list of a series of catalog items (dirent). 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.
- A file in a file system refers to a directory entry in the directory file to which it belongs, and the inode category is "file"; a directory in the file system refers to a directory entry in its parent directory file, and the Inode category is "directory." Visible, multiple "files" can correspond to the same inode; multiple "directories" can correspond to the same inode.
- In a file system, if two files or two directories have the same inode number, they are referred to as "hard link" relationships. are actually aliases for this inode. In other words, each of the files (or directories) corresponding to an inode corresponds to a single directory entry in a directory file of the file system.
- When creating a directory, 3 things are actually done: add an entry in their parent directory file, allocate an inode, and allocate a storage block to hold 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.
- Opening a file by file name is essentially a three-step implementation: First, the operating system finds the inode number corresponding to the file name, and secondly, obtains the inode information through the inode number, and finally, according to the Inode information, finds the block where the file data resides and reads the data.
The Linux system is used
struct inode as the data structure name. BSD-derived system, using the
vnode name, where v represents "virtual file system".
The POSIX standard enforces the behavior of the file system. Each "File system object" must have:
- The file size expressed in bytes.
- The device ID that identifies the device that holds the file.
- The user ID of the file owner.
- The group ID of the file
- The mode of the file, which determines the type of file and its owner, its group, and other users ' access to the file.
- Additional system and user flags (flag) are used to protect the file.
- 3 timestamps, recording the inode itself being modified (ctime, inodechange time), File contents modified (mtime, modificationtime) , the time of the last access (atime, accesstimes).
- 1 links that indicate how many hard links are pointing to this inode.
- A pointer to the file system storage location. Typically, the storage capacity of 1K bytes or 2K bytes is the basic unit.
statYou can use system calls to query the inode number and some meta information for a file.
- A file system object can have multiple names, and these file system object names that have a hard link relationship have the same inode number, which is equal to each other. That is, the first file created does not have a special status. This is different from symbolic links. A symbolic link file has its own inode, and the content of the symbolic link file is the name of the file it points to. So deleting the symbolic link points to the file that will cause this symbolic link file to be wrong in the access times.
- Deleting a file or directory is actually reducing the number of links to its inode by 1. This does not affect other hard links that point to this inode.
- An inode if there is no hard link, the Inode has a link count of 0, and the file system reclaims the storage block pointed to by the inode and reclaims the inode itself.
- From an inode, it is often impossible to determine which file name is used to find this inode number. When a file is opened, the operating system actually throws out the file name, leaving only the inode number to access the contents of the document. The library function getcwd () is used to query the absolute path name of the current working directory. The implementation is to search the inode of its parent directory from the Inode of the current working directory, and finally spell out the name of the entire absolute path.
- Historically, hard links to catalogs are possible. This allows the directory structure to be a forward-only graph, rather than a normal tree. A directory can even be a parent directory of its own. Modern file systems generally prohibit these confusion states, only the root directory remains a special case: the root directory is its own parent directory.
ls /..is the content of the root directory.
- When a file or directory moves inside the file system, its inode number does not change. File system defragmentation may change the physical storage location of a file, but its inode number does not change. Non-Unix fat and its derived file system are not able to achieve the same characteristics of inode.
- It is easy to install a new library in the Inode file system. When some processes are using a library, other processes can replace the inode number of the library file name to the newly created inode, and subsequent access to the library is automatically directed to the contents of the new library file pointed to by the new inode. This reduces the need to restart the system when replacing the repository. The old Inode has 0 links, and the old Inode and old function library files are automatically reclaimed by the system after the process using the old library is finished.
stat meta-information data of the inode corresponding to the query and display of a file name.
- To view the total number of inode and the number of used files in the file system, you can use
- To see how many bytes the inode itself occupies, you can use
sudo dumpe2fs -h /dev/hda | grep "Inode size"
Many programs used by system administrators often use inode numbers instead of filenames to access file systems. For example, a disk integrity checker
pfiles . Therefore, it is necessary to cross-check the inode number with the file's full path name. Can be used with parameter options
ls with parameter options (
-i do it.
The file system may run out of Inode. This causes the file system to have free storage space, but there is no idle inode available for use. For example, an e-mail server might run out of all the inode with a large number of small files, but it does not fill the file storage space.
Modern file systems such as JFS and XFS are able to dynamically increase the inode, thus not exhausting the inode.
- Inode Definition. The Linux information Project. September, 2006 [2010-01-12].
- Linux Kernel List Archive. Retrieved on 2011-01-12.
- Anatomy of the Linux File System
- Inode definition
- Great and Clear explanation on Inodes, symlinks, hardlinks
- Understanding Inode
- Learn more about the inode of Linux one day
The inode of the Linux file system