Linux file system inode and STAT commands

Source: Internet
Author: User

What is an inode

In the unix/linux system, on the surface, the user opens the file by file name, in fact, the system inside this process is divided into three steps: First, the system to find the file name corresponding to the inode number, and secondly, through the inode number, to obtain inode information; Based on the Inode information, locate the block where the file data resides and read the data.

The area of the stored file meta-information (the creator of the file, the date the file was created, the size of the file, etc.) is called the Inode, and the Chinese name is "Index node".


How to view Inode

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/71/F4/wKiom1XbORez9qzzAASb-1cGDwY323.jpg "title=" B ' aot3zwzoq~) tl[ot6a39g.jpg "alt=" Wkiom1xborez9qzzaasb-1cgdwy323.jpg "/>

The stat command can view the details of a file, including

Size: File size (in bytes)

Blocks: The number of blocks, where 8 does not refer to the file system block, where the block should be referred to as sector (sector, 512Byte), 8Blocks equivalent to the file system 1Block (4096Byte)

IO BLOCK: Size of blocks in file system

Regular file: Types of files

Access: File permissions

Uid: File Owner

GID: Filegroup

Atime: Last Access time

Mtime: Last Modified time (time shown in ls-l)

CTime: Last state change time

In addition, stat-f view the file system Information


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 .

Df-i

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/71/F4/wKiom1XbPW-zHSIcAAHfS-5FXOo429.jpg "title=" 9] Jtyld92gfoy0y@1h9$k_d.png "alt=" Wkiom1xbpw-zhsicaahfs-5fxoo429.jpg "/>

To see the size of each inode node , you can use the following command:

Dumpe2fs-h/dev/hda | grep "Inode Size"

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/71/F1/wKioL1XbP_vzvmK8AADRd5i0rk0869.jpg "title=" Nk0952x~s{zwkt51s]b39c3.png "alt=" Wkiol1xbp_vzvmk8aadrd5i0rk0869.jpg "/>

Since each file must have an inode, it is possible that the inode has been exhausted, but the hard disk is not yet full. At this point, you cannot create a new file on your hard disk.


What's the use of inode?

The Inode stores the meta-information of the file, and for some files that cannot be deleted directly through the RM filename, such as the file name "--file", it can be deleted using the inode number:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/71/F9/wKioL1XcFBKB7mUcAAKKDDGXn5w723.jpg "title="}g}e}[ [G[381$ry8klz8nt0.png "alt=" Wkiol1xcfbkb7mucaakkddgxn5w723.jpg "/>

Of course, you can also use RM----file or RM./--file Way

Linux file system inode and STAT commands

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.