Talking about the Inode

Source: Internet
Author: User

1. Initial knowledge of the Inode:

The file is stored on the hard disk (the minimum storage unit of the hard disk is "sector" (sector), 512 bytes per sector)

When the operating system reads the hard disk, it reads a block (8 sector) at once.

The smallest unit of block-to-file access consisting of multiple sectors

File data is stored in "blocks"

Store file meta-information-->inode (index node)

2.inode contains the meta-information of the file, its contents:

File bytes, user ID of file owner, group ID of file, read, write, execute permission, file timestamp, number of links (that is, how many file names point to this inode), File data block location

(all file information except for filename exists in inode)

3. View Instructions

Stat Example//view inode information for a file

sudo dumpe2fs-h/dev/hda | grep "inode size"//view the size of each inode node

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

Ls-i//The file name and inode number in the entire directory file

ls-i Example//View the inode number for the file name

4. When the hard drive is formatted, divide the hard drive into 2 zones:

Data area (storing file data)

Inode Area (inode table, storing information contained in inode)

5. (1) Hard link

Unix/linux allows you to access the same content using different filenames. Changes to the contents of the file affect all file names, but deleting one file name does not affect access to another file name. (inode number Same)

Create: ln source file Destination file

Features: There is the same inode number, only the file name is different (the file has the same inode and data block);

Only existing files can be created;

The directory cannot be created, only the file can be created;

Delete a hard-link file without affecting other files with the same inode number

(2) Soft link (soft link or symbol link)

The inode number for file A and file B is different, but the content of file A is the path to file B. When you read file A, the system automatically directs the visitor to file B. So, regardless of opening that file, the final reading is file B. --At this point, file A is called "soft link" (or "symbolic link") of File B. File a depends on file B, if you delete file B, open file A will error "No this file or directory."

Eg:ln-s test.c (B) try.c (A)

So Try.c (A)-->test.c (B)

The soft link has its own inode number and user data block.

Create: Ln-s source file or directory destination file or directory

Features: soft links have their own file attributes and permissions;

Soft links can be created for nonexistent files or directories;

Soft links can be created for files or directories;

When you create a soft link, the connection count does not increase;

Deleting a soft link does not affect the file being pointed to, but if the file being pointed to is deleted, the associated soft link becomes a dead link (if the path file being pointed to is re-created, the dead link can revert to the normal soft link)

6. The biggest difference between soft links and hard links:

File a points to file B's file name instead of the inode number of file B, and the number of inode links in file B does not change.

This article is from the "Voice of the Heart" blog, be sure to keep this source http://ljy789.blog.51cto.com/10697684/1761894

Talking about the 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.