The meaning of the inode under Linux and the Inode-based hard link soft link

Source: Internet
Author: User

The operation of the file system is related to the operating system's archival data, the newer operating system's archival data, in addition to the actual contents of the file, usually contains a lot of attributes, such as the Linux operating system file permissions (RWX) and file attributes (owner, group, time parameters, etc.). The file system will usually store the two parts of the data in separate chunks, with permissions and attributes placed in the inode, and the actual data in the block. In addition, there is a super block (Superblock) that records the overall information of the entire file system, including the total number of inode and block, usage, surplus, etc.

Each inode and block is numbered, with three data meaning:

    • Superblock: Record The overall information of the sub-filesystem, including the total amount of inode/block, the amount of use, the amount of surplus, and the format and relevant information of the file system;

    • Inode: Records the properties of a file, a file occupies an inode, and records the block number of the file's data;

    • Block: The actual record of the contents of the file, if the file is too large, will occupy more than block.

Since each inode and block is numbered, each file occupies a block number in the Inode,inode that has the file data placed. So, what we can know is that if we can find the file Inode, then you will naturally know the block number of the data placed in the file, and you will be able to read the actual data of the file.

This is a more efficient approach, because our disk will be able to read all the data in a short period of time, read and write performance is better.

This method of data access is called the file system at index time (indexed alloction).

Inode table:

The file data recorded by the Inode has at least those below:

    • The access mode of the file (Read/write/excute);

    • The owner and group of the file (Owner/group);

    • The capacity of the file;

    • The time the file was established or changed in status (Cyime);

    • Last read time (atime);

    • Time of Last modification (mtime);

    • Flags (flag) defining the profile characteristics, such as setuid ...;

    • The direction of the real content of the file (pointer);

The number and size of the inode is also fixed when it is formatted:

    • Each inode size is fixed to 128bytes;

    • Each file will only occupy one inode;

    • The number of files the file system can establish is related to the number of inode;

    • When the system reads the file, it needs to find the inode and analyze whether the permissions recorded by the inode are consistent with the user, and if so, it can begin to actually read the contents of the block.

Inode to record a lot of data, but it is only 128bytes, our system defines the Inode record block number area as 12 direct, a simple connection, a double simple connection with a three indirect record area.


"Hard Link"
A hard connection is a connection that is made through an index node. In a Linux file system, a file saved in a disk partition, regardless of the type, assigns a number to it, called the index node number (Inode index). In Linux, multiple file names point to the same index node that exists. In general, this connection is a hard link. The function of a hard link is to allow a file to have more than one valid pathname so that the user can establish a hard connection to the important file to prevent "accidental deletion". The reason for this is as above, because there is more than one connection to the index node that should be the directory. Deleting only one connection does not affect the index node itself and other connections, and the connection to the file's data block and directory will be released only if the last connection is deleted. That is, the condition that the file is actually deleted is that all the hard connection files associated with it are deleted.

When using a hard link, the disk space and the number of inode does not change, but the hard link can not cross the file system, the nonexistent file name and the directory can not be connected.


"Soft link"

Another kind of connection is called symbolic connection (symbolic link), also called soft link. A soft-link file has a shortcut similar to Windows. A soft-connect file is just a token of its source file. When we delete the source file, the link file cannot exist independently, although we still keep the file name, but we can not view the contents of the soft connection file.

Since the file created by the soft link is an independent new file, it will occupy the inode and block.


This article is from the "fringe" blog, so be sure to keep this source http://ab6107.blog.51cto.com/10538332/1761457

The meaning of the inode under Linux and the Inode-based hard link soft link

Related Article

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.