My view on the Linux inode

Source: Internet
Author: User

The Linux hard disk is organized as: Boot Zone, super block (superblock), index node (inode), data Block (DataBlock), directory block (Diredtory block). Where the Super block contains the overall information about the file system on that hard disk or partition, such as the size of the file system; The data structure behind the Super block is an index node, which contains almost all the information about a specific file, such as access to a file, owner, size, settling time, and corresponding directory block and data block. A data block is a location that really stores the contents of a file. However, the name of the file is not included in the index node, and the filename is placed in the directory block. The directory block contains the name of the file and the index node number of the file.

The hard disk disc is round, each disk has a read and write Head (head), the head is fixed, so that the hard disk disc rotation for a week, the track is track. A collection of the same track numbers for all platters within the hard disk becomes a magnetic column (Cylinder). Each track is divided into many areas, each of which is called a sector (Sector) hard disk with the smallest storage unit called "Sector" (Sector). Each sector is stored 512 bytes (equivalent to 0.5KB).

The first sector of the hard disk's 0 tracks is called the MBR, and its size is 512 bytes, and this area can be divided into two parts. The first part is Pre-Boot area (pre-boot area), accounting for 446 bytes; The second part is the partition table area (partition table), which is 66 bytes, which is equivalent to a small program that determines which partition is marked as active partition and then reads the boot area of that partition. and run the code in that area. Does not belong to any operating system, nor can it be read with the disk operation commands provided by the operating system. However, we can read out the contents of the sector using the INT13h 2nd function provided in Rom-bios, and also use the DISKEDIT.EXE in the software tool Norton8.0.

When the operating system reads the hard disk, it does not read each sector, so the efficiency is too low, but the one-time continuous reading of multiple sectors, that is, one time to read a block. This "block", composed of multiple sectors, is the smallest unit of file access. "Block" size, the most common is 4KB, that is, eight consecutive sector to form a block. The size of the block is determined when the partition is formatted.

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 inode contains meta information for the file, specifically the following:

* 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

eg

6816307-rw-r--r--1 workherd root 1073741824 Sep 11:22 test1126

File: ' test1126 '
size:1073741824blocks:2097160 IO block:4096 Regular file
device:802h/2050dinode:6816307 links:1
Access: (0644/-rw-r--r--) Uid: (502/lixiaod) Gid: (0/root)
Access:2017-09-10 11:22:08.607120512 +0800
Modify:2017-09-10 11:22:19.665120370 +0800
Change:2017-09-10 11:28:02.053153370 +0800

Linux can locate files on disk by using the blocks and size parameters in the file meta information.

My view on the Linux inode

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.