Linux File System (inode and block)
Linux File System (inode block superblock): The file attributes/permissions set for each operating system are not the same. to store the data required for these files, partition formatting is required, to become a file system format available to the operating system. In linux, the file format is Ext2/Ext3. Now it seems that Ext4.windows is vfat or NTFS. Linux File System: In addition to the actual file content, file data of the operating system also has many attributes, such as file permission (rwx) and file attributes (owner, group, and time parameter ). The file system usually stores these two parts of data in different blocks. Put the permission attribute in inode, and put the actual data in the data block. Another super block records the overall information of the file system, including the number and usage of inode and block. Inode: records file attributes. A file occupies one inode and records the block number of the data in the file. block: Actually records the file content, if the file size is too large, multiple blocks will be occupied. super block: records the overall information of the file system, including the total amount, usage, and remaining amount of inode/block, and the format and related information of the file system. Each inode and block is numbered, and each file system occupies one inode. inode contains the block number for storing file data. We can find the inode of the file, find the block number of the data stored in the file, and then read the data. This data access method becomes an indexed file system. This type of file system generally does not require frequent disk fragmentation. The U disk is in the FAT file format, and each block number is recorded in the previous block number. Therefore, the Data Reading performance is poor and it takes a long time to fragment. In linux, The Ext2 file system has planned inode and block at the beginning. Unless it is re-formatted (or the file system size is changed using commands such as resize2fs), inode and block will not change after they are fixed. If the file system is too large, it is difficult to manage all inode and blocks together. Therefore, the Ext2 file system is divided into multiple block groups during formatting ), each block group has an independent inode/block/super block system. The data block Ext2 file system supports three types of blocks: 1 K, 2 K, and 4 K. The block is fixed during formatting, and each block has a number. Note that the maximum disk capacity supported by the file system is different from that supported by a single file. If the block used is too small, two more blocks are used for a file, and inode records are increased to reduce read/write performance. If the block is too large and the file size is small, the remaining space will be unavailable and resources will be wasted. Inodetable (inode table. the file data recorded by inode must contain at least the following content: Access Mode of the file; Owner and all groups of the file; size of the file; the time when the file is created or the status changes (ctime); the last read time (atime); the last modified time (mtime); the point of the file's real content. Inode also has the following features: Each inode is fixed to 128 bytes, and each file occupies one inode. inode needs to be found before the system reads the file, it also analyzes whether the permissions recorded by inode are consistent with the user. If yes, the block content can be read. However, there is a problem: there are many file attributes to be recorded, and a file may have many blocks, while inode is too small (4 bytes is required to record a block). What should I do? In linux, the solution is to define the inode record block number as 12 direct, indirect, dual indirect, and triindirect record areas. The total number of blocks that can be recorded is 12 + 256 + 256*256 + 256*256*256 (K) = 16G, which only meets the condition where the block size is 1 K. Superblock records the overall situation of the file system. For example, the Mount time of the file system, the time when data was last written, and the time when the last disk (fsck) was verified. There is also a validbit value. If the file system has been mounted, the validbit value is 0. If not, the validbit value is 1. After learning about the concept of a file system, check the file system and run the following command: # dumpe2fs [-bh] device file name-B lists the parts that are retained as bad channels-h only lists superblock data and does not list other sections. Example: # dumpe2fs/dev/hdc2