Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How inode works

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

How inode works:

If you compare blcok to the contents of a book, then inode is the directory of the book. Inode records the metadata information of the file, such as permissions, size, master group, timestamp, and the location of the data block. What is stored in blcok is the real data.

Block: the default size of each blcok is 4k (which can be modified when creating a file system), and each blcok can only be used by one file. For example, if there is a 1k file, put the file in block, then the remaining 3k in the block cannot be used, and the size of the blcok needs to be determined according to the actual application. For example, if the block size is now set to 1k and there is a 10k file, then 10 blocks are needed. This leads to too long addressing time, which will lead to performance degradation. If you set the block to 10k now, there will be a 1k file, which will lead to a waste of space, so the block size needs to be determined according to the actual situation.

Inode:inode also needs to occupy block blocks.

Direct pointer: the first 12 inode pointers point to 12 4k block blocks, so a total of 48k files can be pointed.

Indirect pointer: 13inode. Each time you point to a block, you will consume 4byte. Then a block is 4k, in which metadata is stored. A total of 1024 blocks can be pointed to, so the file size that can be pointed to is 4K*1024=4M.

Triple pointer: if the indirect pointer is placed in 1024 blocks of inode, it will point to 1024,1024,4G files.

Example of file search process: find c file in / a/b/c

First of all, the system can view the names and corresponding inode numbers of all files in the root directory according to the root inode, so that you can find a file and the corresponding inode number, find the corresponding inode in the inode number of a, and then you can see the names and corresponding inode numbers of all files under directory a, so you can find the b file and the corresponding inode number. According to the inode number of b, you can find the inode of b. So you can see the names and inode of all the files in the b directory, so you can find the c file.

Cp and inode: new files

Rm and inode:

Delete the inode of the original file, put the data block in the free list, and the data deleted by mistake can also be restored. If a new file is imported, it will find out which blocks have been used and which blocks are left by super fast, then the new inode will be obtained again. When free blocks are allocated, files deleted before this time cannot be restored.

Mv and inode:

If you are in a partition, you just change the location of the pointer mapping, and the inode does not change.

If you are not in a partition, copy the data to the destination file first, and then delete the source file.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report