Soft link and hard link details

Source: Internet
Author: User

Soft link and hard link details

Today, we will introduce the following soft links and hard links.

I. What is inode?

To understand inode, start with file storage.

1. The file is stored on the hard disk. The minimum storage unit of the hard disk is 512 bytes, which is equivalent to 512 bytes.

2. When the Operating System reads a hard disk, it does not read multiple sectors. This is too inefficient. Instead, it reads multiple sectors consecutively at a time, that is, one "Block" should be read at a time ",

Is the minimum unit for file access. The most common size of a block is 4 kb.

3. the file data is stored in blocks. Obviously, we must also find a place to store the file metadata, such as the file creator, creation date, the file size is called inode. index Node

II. Inode number

1. Each inode has a number. The operating system uses the inode number to identify different files.

2. linux uses inode numbers instead of file names to identify files.

3. On the surface, the user opens the file through the file name. In fact, the internal process of the system is divided into three steps.

First, the system finds the inode number corresponding to the file name, and then obtains the inode information through the inode number. Finally, based on the inode information, it finds the block where the file data is located and reads the data.

3. Hard Link

Multiple File Names correspond to one inode number,

This means that you can access the same content with different file names. Modifications to the file content will affect all file names. However, deleting a file name does not affect access to another file name.

Number of hard links: There are several file names corresponding to one inode, and the number of hard links is several

Deleting a file name will reduce the number of links in the inode node by 1. When this value is reduced to 0, it indicates that no file points to this inode, and the system will reclaim this inode number, and the corresponding block area, that is, the data zone.

4. Soft link

Although the inode numbers of file A and file B are different, the content of file A is the path of file B. When reading file A, the system will automatically direct the visitor to file B. Therefore, no matter which file is opened, file B will eventually be read. In this case, file A is called the "soft link" of file B ".

This means that file A depends on file B. If file B is deleted, an error will be reported when file A is opened.

File A points to the file name of file B, instead of the inode number of file B. The number of inode links of file B does not change.

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.