Inode structure and soft links and hard links

Source: Internet
Author: User

First look at block (concept of block), block is the smallest unit of file access, usually 8 sectors is a block, and each sector size is 512 bytes is 0.5K, so the size of a block is 8*0.5k=4k.


The system uses Inode to identify files


You can use the command stat to view inode information for a file, such as stat client.c

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7E/EA/wKioL1cM5ViAlEdLAAAxqS5VukI792.png "title=" Stat.png "alt=" Wkiol1cm5vialedlaaaxqs5vuki792.png "/>

You can see that the file information except for the filename is in the Inode

Therefore, the inode is the information that holds the file, called the index node


Command:

Stat file name//view inode information for a file

Df-i//View the total number of inode and quantity used for the hard disk partition

Ls-i filename//view inode number of the file

Df-h//block



A file consists of two parts: one is its meta information and the other is the file data

The file data is placed on the sector, but each time the operating system reads the data in blocks as the smallest unit

File meta information is stored in an area called Inode

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/7E/ED/wKiom1cM7ujhKe55AAAg2nDCsHM814.png "title=" Inode.png "alt=" Wkiom1cm7ujhke55aaag2ndcshm814.png "/>


Hard link: Two or more files have the same inode number, assuming that two files A and b,a and B have the same inode number, opening either A and B essentially opens a file, and the other file changes for one of them. But deleting one of them does not affect another file.

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/7E/EE/wKiom1cM9HSiF0M_AAAJsm2T9KI523.png "title=" Hard link. png "alt=" Wkiom1cm9hsif0m_aaajsm2t9ki523.png "/>

Create a hard-link ln source file destination file (the number of links in the inode struct is added 1)


Soft link: or fake A and b two files, and their two inode number is different, the content of a file is the path of B, that is, open any one of the files will open file B, called a is B soft link.

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7E/EB/wKioL1cM9T6DYXG7AAAGrRnsHMg912.png "title=" Soft links. png "alt=" Wkiol1cm9t6dyxg7aaagrrnshmg912.png "/>

Create a soft link ln-s source file destination file

Inode structure and soft links and hard links

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.