An explanation of inode nodes and hard link concepts

Source: Internet
Author: User

First, Inode node understanding


Inode (Index node): The area where file meta information is stored


Sector: In Linux systems, the smallest unit of storage, typically 512 bytes (0.5KB)


Block:linux the smallest access area in the system (when the operating system reads the hard disk, reads multiple sectors at once, that is, one block at a time), each block typically contains 8 sectors with a size of 4k


1, after reading the above three noun explanation, then look at the role of the Inode:


1.1, the file data in the block (one time can occupy multiple sectors, and a minimum of one block), then the file's meta-information (creator, creation date, size, etc.) need to find a place to store, this storage area is the inode (commonly known as the Index node), each file has an inode to store the file's meta-information


1.2. The following information is stored in the General inode node:


* Number of bytes in the file

* User ID of the owner of the file

* The group ID of the file

* file read, write, execute permissions

* File timestamp, total three: CTime refers to the time when the inode was last changed, mtime refers to the time when the file content was last changed, atime refers to the time when the file was last opened.

* Number of links, that is, how many filenames point to this inode

* Location of File data block


1.3, Command: Stat + file name, view the inode information of a file


1.4. Inode Size:


The inode also consumes hard disk space, so when the hard disk is formatted, the operating system automatically divides the hard disk into two zones. One is the data area, the file data is stored, and the other is the Inode area (inode table), which holds the information contained in the Inode.

The size of each inode node is typically 128 bytes or 256 bytes. The total number of inode nodes, given at the time of formatting, is usually set to one inode per 1KB or 2KB each. Assuming that the size of each inode node in a 1GB hard disk is 128 bytes, and one inode is set per 1KB, the Inode table will be about 128MB in size, accounting for 12.8% of the entire drive.


You can use the DF command to view the total number of inode per hard disk partition and the quantity that is already in use.



2, then look at the Linux system read the file process:


2.1. The system finds the inode number corresponding to this file name


2.2, the system according to this inode number to read the meta-information of the file


2.3, according to the Inode information, find the file data block, read the data



Second, hard link concept understanding


We know that, in general, the file name and Inode are one by one corresponding relationship (however, in fact the system will only recognize the inode number of the file, and the so-called file name is the alias we defined for the inode), but in the Linux system, there can be multiple file names corresponding to an inode number case, This is called a hard link.


Command: LN file name 1 file name 2

This command creates a hard link so that multiple file names correspond to an inode, and if you modify the contents of one of the files, the contents of the other files change, but if you delete one of the files, it does not affect access to the other file.


Finally, we can delete a file that cannot be deleted for some reason by deleting the inode node


Command: RM ' find./-inum 388666 '


This article is from "The Miracle Teenager" blog, please be sure to keep this source http://raffaelexr.blog.51cto.com/8555551/1719726

An explanation of inode nodes and hard link concepts

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.