Linux Classroom Assignment 2 (how the Inode works and the difference between soft and hard connections)

Source: Internet
Author: User

How the Inode works:

A file includes metadata and data content, metadata is stored in the Inode table, and the data content is stored in block blocks, and the Inode holds metadata entries for each file, including some basic meta-data such as Mode,ownership, Sizetimestamp also holds pointers to data, which are divided into direct pointers and indirect pointers, double indirect pointers, and even three indirect pointers. The direct pointer represents a block that points directly to the data content, the next layer of the indirect pointer is a block of data, but the data block is not the data content of the file, but a pointer data block, if the block size is 4k, each pointer occupies 4 bytes, then this pointer data block can hold 1024 pointers, These pointers then point to the real data content. Similarly, if it is a double indirect pointer, each pointer in the pointer data block points to 1024 new pointer data blocks, these new pointer data blocks, each pointer data block contains 1024 pointers, which point to the real data content. The triple pointer continues down the analysis.


The difference between soft and hard links:

Soft Link: A soft link is stored in the path of another file, you can see it as a normal file, but its file content is the path of the other files to point to. Deleting a soft link does not affect the original file being pointed to, but if the original file being pointed to is deleted, the associated soft connection cannot be viewed.

Soft Connect ln-s Original file path soft connect

When creating, be sure to indicate the original file path, if not write, the current path must be in this soft link directory
relative path: relative to the path of a soft-linked file, not to the current working directory

You can create soft links to a catalog, create them across partitions, and have their own file properties and permissions for soft-linked files

[Email protected] 2text]$ ls/home/xiaoshui/f1 F11 text[[email protected] 2text]$ ls[[email protected] 2text]$ ln-s. /.. /.. /.. /.. /.. /HOME/XIAOSHUI/F1 F111[[email protected] 2text]$ ls-ltotal 0lrwxrwxrwx 1 Xiaoshui xiaoshui (16:11 f111) /.. /.. /.. /.. /.. /home/xiaoshui/f1

Of course, the original file path can also write absolute path

[[email protected] 2text]$ ln-s/home/xiaoshui/f1 f111[[email protected] 2text]$ ls-ltotal 0lrwxrwxrwx 1 Xiaoshui Xiaos Hui 16:14 f111-/home/xiaoshui/f1

Hard links: It can be understood that a person has two names, hard links are the same, it has multiple filenames, and each file name points to the same inode number, because the hard link is a file with the same inode number only different file name, so deleting a hard-link file does not affect the other have the same inode Number of files.

Hard links cannot span partitions, cannot cross file systems, and cannot be directories.

[[email protected] 2text]$ Touch F1[[email protected] 2text]$ lsf1[[email protected] 2text]$ ls-i67410541 f1[[email prote CTED] 2text]$ LN F1 f2[[email protected] 2text]$ ls-i67410541 F1 67410541 F2

You can see that the inode number is the same.

This article is from the "Endless Learning" blog, please be sure to keep this source http://dashui.blog.51cto.com/11254923/1831792

Linux Classroom Assignment 2 (how the Inode works and the difference between soft and hard connections)

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.