In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Inode, data block and super block
1. Inode is used to record file attributes, permissions and other information; a file occupies an inode, and inode also records the location of the file's data block. The size of inode is 128,256 bytes.
2. Data block: used to store the actual contents of the file. The block size is 1K, 2K, and 4K bytes.
3. Super block: record the overall information of the file system, including the total amount of inode and data block, amount used, remaining Dan, volume label, file system format and other related information. You can use tune2fs-l Partition_Name to view it.
Note: take the ext2 file system as an example, for a 128byte inode, in addition to storing information such as the permissions attributes of the file, only 12 4-byte files can be stored to point to the block number. For a large file, tens of millions of data blocks are needed to store the contents of the file. How do I do this? In addition to 12 direct data points, inode also has an indirect, a double indirect, and a three indirect recording area. The so-called indirect meaning is that the direct point of the inode will point to a data block, which does not store the data, but the number of the data block of the file stored. For 1K blocks, 256 points can be stored. For 256KB data blocks, the file size can be 256KB; double indirect storage can store 64MB data, three indirect storage can store 16G files; for 2K and 4K size and other file systems, the algorithm is different. But all of them borrow data blocks to store the data block numbers.
Second, how to access files
Each file system is divided into several block group internally, and each block group includes the following:
1. Super block: the total amount of inode and data chunks, the remaining number, the size of inode and data chunks, retention and other information. The first block group must have super blocks, and the subsequent block groups, some have and some do not.
two。 File system description: a block that describes the beginning and end of a block group, and which block each section (super block, comparison table, inode comparison table, data block) lies between, which can also be viewed with dumpe2fs.
3. Block bitmap: used to record which block is empty and which has been used.
4. Inode bitmap: used to record which inode is empty and which has been used.
5. Inode table: used to store file attributes and the file data block number
6. Data block: used to store the actual contents of the file.
When accessing files, first check whether the user has write and execute permissions to the directory; then the system queries through inode bitmap which inode tables are empty, and writes the attributes of the new file to the empty inode table; according to the block bitmap to find which data block is empty, then you can write the file contents to these block; update inode bitmap and block bitmap, and update the information of the super block.
Third, how the system reads the contents of the file through the path
As an example, find the / etc/passwd file
1. First look up the inode number of /, there is a record / corresponding data block in the inode of /.
two。 Find the inode corresponding to the etc directory in the data block of /
3. Read the inode table corresponding to the etc directory and find the data block of the etc directory
4. In the data block of the etc directory, find the inode number of the passwd file
5. Read the data block pointing in the inode of the passwd file and read out the contents.
Summary: start from the root directory, first find inode, through inode to find the corresponding data block; in the data block, there are two cases: 1. If the file is a directory, the data block records the file names of its subordinate subdirectories and files and the corresponding inode; 2. 0. If the file is a non-catalog file, the data area records the contents of the file. Read the file in a loop through inode--- > block--- > inode--- > block. In this process, you need to check the user's permissions on directories and files.
Fourth, hard chain pull and soft link
1. Hard links are multiple file paths to the same inode; directories do not support hard links and cannot cross file systems, and creating hard links increases the inode count.
two。 Soft links point to the actual access path of the file, which can span the file system and support the creation of soft links to directories. Deleting soft links will not affect the original file.
5. MBR
The first sector of the storage device, the first 512 bytes, is called the boot record
1. The structure of the master boot record
The master boot record is only 512 bytes and does not hold much. Its main function is to tell the computer which location of the hard disk to find the operating system.
The master boot record consists of the following three parts:
a. 1-446 bytes: machine code that calls the operating system
b. 447-510 bytes: partition table (Partition table)
c. 511-512 bytes: master boot record signature (0X55 and 0XAA)
two。 Partition table
Hard disk partitions have many benefits. Considering that each zone can install a different operating system, the master boot record needs to know which zone to transfer control to.
The length of the partition table is only 64 bytes, and it is divided into four items, each with 16 bytes. Therefore, a hard disk can only be divided into at most four first-level partitions, also known as primary partitions. The recording area of each group mainly records the cylindrical numbers of the beginning and end of the section.
The 16 bytes of each primary partition consists of the following six parts:
a. The first byte, if 0X80, indicates that the primary partition is the active partition and control is transferred to this partition. Only one of the four primary partitions is active.
b. 2-4 bytes: the physical location of the first sector of the primary partition (cylinder, head, sector number, etc.)
c. Byte 5: primary partition type
d. Bytes 6-8: the physical location of the last sector of the primary partition
e. 9-12 bytes: the logical address of the first sector of the primary partition
f. 13-16 bytes: the total number of sectors of the primary partition.
The last 4 bytes (the total number of sectors of the primary partition) determines the length of the primary partition, that is, the total number of sectors of a primary partition is no more than 2 to the 32th power.
If each sector is 512 bytes, it means that the maximum size of a single partition is no more than 2TB. Considering that the logical address of the sector is also 32 bits, the maximum space available for a single hard disk does not exceed the 2TB. If you want to use a larger hard disk, there are only two ways: one is to increase the number of bytes per sector, and the other is to increase the total number of sectors.
Where the file name is stored and where the attributes of the file are stored
1. A directory is also a file.
two。 The file name of the file is stored in the data block of the directory
3. File attributes, permissions and other information are stored in inode
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.