Linux disk partition management--EXT2 and Ext3 file system logical Structure analysis

Source: Internet
Author: User

This article is from the "Pavel" blog, make sure to keep this source http://pavel86.blog.51cto.com/8349178/1688277

Linux systems support a variety of file systems, the difference between file systems is that different file systems on the same disk partition storage file structure is different. For example, some local tyrants bought 500 flat housing: Some workaholic would be separated from 1 bedrooms, 1 living rooms, 1 kitchens and 5 workstations; Some gourmets will be separated from 3 bedrooms, 3 living rooms, 4 kitchens and so on. The file system is equivalent to partitioning different performance zones for storing data in different ways.

EXT (Extended file system) is a regular filesystem supported by Linux, and this paper explains the logical structure of the two basic file systems in EXT2 and EXT3 models.

EXT2 File System

The Ext2 file system divides the disk partitions into two primary zones: the metadata area (Matadata areas) and the data area . The metadata area is used to store the owner of the file, the group, access rights, timestamps, and file system data and metadata allocation information and other related attributes information, the data area for the real data in the file.

As the size of the physical disk becomes larger and more data is stored, it is sometimes necessary to traverse the entire disk space in order to read and write files, which is very time consuming, so the disk partitions are partitioned into blocks (Block group ) when the file system is created. Each block group has its own metadata area and data area, and they are independently autonomous. The logical structure of the file system is as follows:

The boot block partition refers to the boot sector of the file system, which can be used to install the bootstrapper without needing to occupy the only MBR area on the hard disk, mainly for multi-os hosts.

The internal logical structure of the block group is as follows:

The logical structure of the metadata area and data area in the block group can be seen as shown.

Data area

Data area structure is relatively single, by a number of the same size data block (block), the size of the data block specifications are: 1KB, 2KB, 4KB. The size of the data block is fixed after the file system is formatted and cannot be modified thereafter. For a directory, the data block is used to store the file name and the inode number of that directory; For a file, the data block is used to store the data in the file. Because the size of the block determines the size of a single largest file stored in the file system, and the block size is very much related to the host hosting business type, the size of the data block should be analyzed according to the specific problem.

Meta Data area

The metadata area consists of the Super block, FSD (file system description), Inode table (inode), Inode bitmap(Inode bitmap), and block bitmap(Data block bitmap) 5 parts.

1. Super Block

The super block is used to describe the metadata information for the entire file system: Block size, total block and inode, idle amount, amount taken, file system mount and detection time, and so on, the Super block is critical to the entire file system, so the super block is backed up in multiple random block groups.

2. FSD (file system description)

The file system description is used to describe the metadata information for the current block group, such as the number range of blocks occupied by the block group interval.

3. Inode table (inode tables)

The Inode table holds each file's own Inode entry, and each Inode entry has a fixed size of 128KB, which contains two types of information for the corresponding file: The metadata information for the file and the data block pointer to the file.

3-1. The file metadata information mainly includes: The owner of the file, the group, access rights, time stamp and other related attributes.

3-2. The data block pointer of the file is used to store the address information of the block block where the file stores the data, and 1 Inode entries contain 4 classes of pointers: 12 direct pointers, 1 indirect pointers, a two-level indirect pointer, and a three-level indirect pointer. Where direct pointers can be directed directly to block data blocks, The indirect pointer points to a block of data, and then it points to more block blocks to get more data block space to store file data, level two indirect pointers and level three indirect pointers, and so on. The address label of each block itself occupies the storage space of the corresponding pointer 4 B, so the size of the block blocks can be stored with a different maximum file size.

Take block size 1KB as an example:

12 Direct pointers can specify the block storage space as: 12X1KB=12KB;

1 indirect pointers can specify the block storage space as: 1kb/4bx1kb=256x1kb=256kb

1kb/4bx1kb/4bx1kb=256x256x1kb=65536kb

1kb/4bx1kb/4bx1kb/4bx1kb=256x256x256x1kb=16777216kb

The total size of a single file is: 48+256+65536+16777216KB=16843020KB=16.06GB

# because blocks larger than 2KB are limited by the Ext2 file system itself, this calculation does not apply to blocks of block 2KB or 4KB in size.

4. Inode Bitmap (inode bitmap)

The Inode bitmap uses a single bit in each byte to describe whether the Indoe entry in the corresponding location is idle, and the primary role is to facilitate querying for idle inode entries and traversing the entire inode entry space.

5. Block Bitmap (block bitmap)

The block bitmap principle is similar to the inode bitmap principle, which is to facilitate querying the inode entries in the space and traversing the entire inode entry space.

The above is the logical structure of the Ext2 file system.

=============================================================

EXT3 File System

The Ext3 file system divides the disk partitions into 3 zones: The metadata area, the data area, and the log area, where the (journal area) Log region is the largest difference between the Ext3 file system and the Ext2 file system, as shown in:


The primary function of the log area is to temporarily cache metadata information for a file that is in the I/O operation, and when the file is properly transferred, the file system stores the temporary cached metadata information in the file system's metadata area. The biggest advantage of the log area is that the file system does not need to traverse the entire file system's metadata area to find the faulty block block information when the file information of the I/O operation fails, and only needs to find the temporary cached metadata in the log area, which greatly shortens the query time.

The metadata area and data area of the Ext3 file system are the same as the Ext2 file system, and are not repeated here.

Summary:

Ext Series File system is a relatively basic type of file system on Linux, also need to be mastered, I hope this analysis can help you understand the EXT2 and EXT3 file system logical structure and corresponding functions.

I have limited level, if there is improper understanding of the place, please give correct, thank you very much!

This article is from the "Pavel" blog, make sure to keep this source http://pavel86.blog.51cto.com/8349178/1688277

Linux disk partition management--EXT2 and Ext3 file system logical Structure analysis

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.