Sinsing analysis of the inode in Linux

Source: Internet
Author: User

to say the inode, you have to start from the physical format of the hard disk, the minimum storage unit of the hard disk is the sector, that is, sector, each sector storage 512 bytes. and the general file system will have its own minimum reading and writing unit, it is block, generally can have 1KB, 2KB, 4KB and so on, now more common is 4KB, that is, a continuous eight sector to form a block.

File specific data is stored in the block, so we want to find these blocks, we need to store their meta-information, so there is inode, also known as the index node, we can use stat filename to view the inode information of a file, It mainly contains the number of bytes of the file, the UID of the file, the GID of the file, the read and write permission of the file, the timestamp of the file, the number of links to the file, and the location of the file block. It is important to note that each file must have an inode, so it is possible for the inode to run out of memory, and if the disk is not full at this time, then the file cannot be recreated on disk. We can use the-i parameter of LS to view the specific Inode value.

Because the inode has stored some data information, so the inode also needs to occupy a certain amount of disk space, in the format of the hard disk, the operating system automatically divides the hard disk into two areas, one is the data area, and the Inode area. The size of each inode node is typically 128 bytes or 256 bytes. And the total number of inode nodes, it is in the format of the time has been given, generally no 1KB or 2KB set an inode.

In the *nix system, the directory is also a file, the structure of the directory is also very simple, it is a list of catalog items, it consists of two parts: the name of the file, and the file name corresponding to the inode number. And when each directory is created, two directory entries are generated by default. and. The inode number of the former is the inode number of the current directory, which is equivalent to the hard link of the current directory, and the inode number of the latter is the inode number of the parent directory of the current directory, the same as the parent directory's hard link, so the total number of hard links in any directory is always equal to 2 plus the total number of subdirectories. The subdirectory here contains the hidden directory, where 2 is the hard link to the parent directory and the. Hard link in the current directory.

If the source and destination files point to the same inode, then they are mutually hard links, and the inode information is called the number of links, it records the total number of filenames pointing to that inode, and if we delete a file name, the number of links in the Inode node is reduced by 1. When this value is reduced to 0, the system will retract the inode number and its corresponding block area.

If the file name contains special characters and is difficult to delete, we can delete the file directly by deleting its inode value. If the file is moved or renamed, it simply changes the file name without affecting the inode number. When we open a file, the system uses the Inode to identify the file, which no longer considers the filename, so the system cannot get the file name from the Inode, but can find the inode from the file name.

Sinsing analysis of the inode in Linux

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.