Inquisitive: Ext3/ext4 file system maximum space and single file size algorithm

Source: Internet
Author: User
Tags what file system

Algorithms for prying space and file sizes from the ext3 and Ext4 file systems


Learning the operating system will have to study disk and disk file system, the disk is the underlying physical device, and the file system is the upper layer of management disk tools, file system planning the format of disk storage data, determine how much disk space an operating system can support, how much data space each partition can support, And the size that each file can support. Typically, the most important thing for a system administrator is to know the maximum disk space, the maximum partition space, and the maximum file size. This topic only discusses how these three sizes are calculated, not rote. Know the principle, no matter what file system encountered later, will rule, at least know that the data needed to figure out the size of these three requirements. In addition, here does not talk about the composition of the disk and the layout of the file system, only the calculation method, may involve the relevant knowledge points, please check the relevant information.

Many people may be rote several values, but do not know why this value, here to analyze:

1. Mandatory Requirements

EXT3:

1). ext3 file system uses 32bit block address index space;

2) in the Inode entry, the reference to a block space symbol requires a size of 4byte;

3) for an inode, 12 direct pointer indexes, an indirect pointer index, a double-indirect pointer index, and a three-indirect pointer index are designed

Note:

A. These provisions are determined by the program code of the filesystem itself, which means that it is designed at the time of development, that there is no reason, only what; It is also the same file system;

B. The so-called double-indirect pointer index and the triple-Indirect pointer index refer to the two-level structure and the three-level structure, equivalent to the root file system tree in Linux;

INODE internal structure in ext3 file system:

650) this.width=650; "title=" inode internal structure. png "alt=" wkiol1rubxnqpb5aaaegllmev_m061.jpg "src=" http://s3.51cto.com/ Wyfs02/m00/53/b4/wkiol1rubxnqpb5aaaegllmev_m061.jpg "/>



EXT4:

1). ext4 file system uses 48bit block address index space;

2). In the Inode entry, the mapping to the block is not done using the pointer index, but instead of the pointer by extent, the previous 15 in ext3

The pointer is replaced with 5 extent, and a extent occupies 3byte space; a extent describes a contiguous set of blocks that, when not enough, extent can still pick

The index of the indirect pointer, but with no number limit.

Note : For extent calculation of a single file size algorithm, has not been found out, did not read the source code. If you read the message.

2. Rules of calculation

Good, know the above source code design rules, the following can be calculated.

EXT3:

1). maximum supported file size

The first thing to know, in the Linux file system, a block size can be 1k,2k,4k, when the size of block 4k is the largest. In a Linux system, each file uses an inode number, so to calculate the maximum space supported by a single file, as long as you know how many blocks can be referenced in the inode, When the block takes the maximum value of 4k, the calculated value is the maximum amount of space that can be supported for a single file.

As can be seen from the hard rules above:

A. An inode supports 12 direct pointers, thus representing 12 blocks

B. An inode supports an indirect pointer, which is a pointer to a block chunk that acts as a direct pointer to the final block, where is a block of 4K, pointing to a block to occupy 4byte of space, so the indirect pointer of a block can point to 4k/4byte block, that is 2^10

C. Double indirect pointers eventually point to: 2^10*2^10=2^20 blocks

D. Three indirect pointers final execution: 2^10*2^10*2^10=2^30 blocks

So the final block number is: 12+2^10+2^20+2^30

Then the final size is: (12+2^10+2^20+2^30) X4kbyte

The size of the conversion into TB is: (12+2^10+2^20+2^30) X4KBYTE/1024/1024/1024=4TB

To this, the Ext3 file system, when the block is 4K, it supports a single file size of maximum, 4TB maximum.

Note : Of course, this is the theoretical value, in the industry should know that the actual value and the theoretical value is always a bit biased, but harmless

2) maximum partition size (i.e. file system size)

in the operating system, the file system is for the partition, and one disk must be partitioned before the file system can be formatted (even if you divide all the capacity of the disk into one partition). format file system before you can mount it, you must know exactly how much partition size a file system supports.

In the Ext3 file system, a 32bit block index space is used, and it takes an unsigned integer of int, so the maximum space for a partition is:

2^32*4kbyte=16tb

From this, we know that in Ext3 file system, when block is 4K, the space of one partition will be maximum and the maximum space is 16TB

3) Maximum disk capacity

Sometimes when we need more disk capacity space, we increase the disk to meet the demand. However, when you use the last partition, you will find that the hint does not support such a large space. Why is this?

for the entire disk, because the MBR region exists, and the MBR has 64byte of space can only represent 4 partitions, each partition 16btye to , so the maximum partition supported for the Ext3 file system is 16TB, and the maximum system disk capacity is: 16TB*4=64TB

Note : Here are some questions to ask.

A. Someone asked: Do you say 4 partitions, not logical partitions, partitioning disks with logical partitions can divide many partitions. Isn't that supposed to be unrestricted?

Answer: Logical partitions Expand the number of disk partitions, but logical partitions are also extended from one primary partition in 4 primary partitions, so all logical The space of the partition is simply the expansion of the space of the last largest primary partition.

B. Someone asked: No, in a Linux system, a new disk can be used as a partition and then mounted to a directory in the system.

Answer: The new disk can be mounted to a directory in the system, but for the new disk It is also under the Ext3 file system, the new disk itself The maximum is also 64TB. Therefore, this is based on the ext3 file system, the block size of 4K can support the maximum disk capacity, beyond this size, the partition table is not recognized. Never understand the amount of space the operating system can use.

EXT4:

1) Maximum space for a single file

since EXT4 is no longer using pointers as a block mapping, instead of using extent to manage the number of blocks that can be described, I do not understand extent What is a mechanism, so do not calculate. But the consistent argument is that a single file can be 16TB large, equivalent to the maximum partition size of ext3.

2) maximum partition size (i.e. file system size)

The EXT4 uses a 48bit block address index space, so the size is: In the case of block 4k.

2^48*4kbyte=1eb=1024pb=1024*1024tb

This space can be said to be sufficient in the present environment.

3) Maximum disk capacity

According to EXT3 's analysis conclusion: 1EB*4=4EB

OK, so much to say, do not know you understand No. Anyway, I understand. (^_^)


This article from the "Life and death as the Dream Mo Sentimental" blog, please be sure to keep this source http://mingyang.blog.51cto.com/2807508/1580314

Inquisitive: Ext3/ext4 file system maximum space and single file size algorithm

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.