Main differences between CentOS file system ext3 and ext4

Source: Internet
Author: User
For a long time, ext3 is the default file system of many linux distributions. now ext4 has been released, in addition, some releases have started to use ext4 as the default file system (in fact, ext4 was initially used as the extension of ext3, but in order to ensure the stability of ext3 and other reasons, many people oppose the extension of ext3 directly, so it is used as an ext4 project separately ). Ext3 still uses 15 inode to search for data blocks. the first 12 are direct data blocks that direct to the data blocks that store data.

For a long time, ext3 is the default file system of many linux distributions. now ext4 has been released, in addition, some releases have started to use ext4 as the default file system (in fact, ext4 was initially used as the extension of ext3, but in order to ensure the stability of ext3 and other reasons, many people oppose the extension of ext3 directly, so it is used as an ext4 project separately ).

Ext3 still uses 15 inode to search for data blocks. the first 12 are direct data blocks that direct to the data blocks that store the data. next they are level 1 indirect blocks and level 2 indirect blocks, respectively, level 3 indirect block, such:

Here, point is also a data block. now it is used for data block indexing. the header file of ext3 is defined as __u32 I _block [EXT3_N_BLOCKS];/* Pointers to blocks */, therefore, the ext3 file system limit can be calculated:

Maximum partition:
Because it defines the 32-digit unsigned digits, the block range that may be located may be 2 ^ 32, that is, 4 GB. if the size of a block is 4 kB, therefore, it is 4 GB * 4KB = 16 TB.

Maximum file:
Point to 12 data blocks. The maximum size of a level-1 indirect block is block size/4. the block size is the size of the data block. because an index is 4 bytes, divide it by 4, after calculation, the total number of blocks that can be used for the maximum file is 12 + (block size/4) + (block size/4) ^ 2 + (block size/4) ^ 3. if the block size is 4 K, it is (12 + 2 ^ 10 + 2 ^ 20 + 2 ^ 30) * 2 ^ 12 is approximately 4 T.

To overcome the size limit of ext3, ext4 uses a 48-bit data block index space and uses the following structure to replace inode indexes:
Struct ext3_extent {
_ U32 ee_block;/* first logical block extent covers */
_ 2010ee_len;/* number of blocks covered by extent */
_ 2010ee_start_hi;/* high 16 bits of physical block */
_ U32 ee_start;/* low 32 bigs of physical block */
};

In this way, when you search for data blocks, you do not create an index for each block, and use continuous data blocks, that is, to indicate the starting position and the number of consecutive blocks respectively, disk I/O efficiency and data block search efficiency are greatly improved, so ext4 file systems are superior to ext3. Because the 48-bit index space is used, the maximum size of the file system is 2 ^ 48 * 4KB = 1EB in the case of a 4 KB block size. However, due to tool restrictions, only 16 TB partitions can be used.

Main differences between EXT3 and EXT4

Linux kernel has officially supported the new file system Ext4 since 2.6.28. Ext4 is the ultimate version of Ext3. it modifies some important data structures in Ext3, not just like Ext3 for Ext2, but adds a log function. Ext4 provides better performance and reliability, as well as richer features:

1. compatible with Ext3.Execute several commands to migrate from Ext3 online to Ext4 without reformatting the disk or reinstalling the system. The original Ext3 data structure is retained, and Ext4 is used for new data. of course, the entire file system also obtains a larger capacity supported by Ext4.

2. larger file systems and larger files.Compared with Ext3's support for a maximum of 16 TB file systems and a maximum of 2 TB files, Ext4 supports 1 EB (1,048,576 TB, 1 EB = 1024 PB, 1 PB = TB) file systems, and 16 TB files.

3. unlimited number of subdirectories.Ext3 currently only supports 32,000 subdirectories, while Ext4 supports an unlimited number of subdirectories.

4. Extents.Ext3 uses indirect block Ing. when operating large files, the efficiency is extremely low. For example, for a 100 MB file, a ing table of 25,600 data blocks (4 KB for each data block) must be created in Ext3. Ext4 introduces the popular extents concept in modern file systems. each extent is a set of continuous data blocks, the preceding file indicates that the file data is stored in the next 25,600 data blocks, which improves the efficiency.

5. multi-block allocation.When writing data to the Ext3 file system, the Ext3 data block distributor can allocate only one 4 KB block at a time. to write a 100 MB file, it is necessary to call the 25,600 data block distributor, the multiblock allocator (mballoc) multi-block allocator of Ext4 supports allocating multiple data blocks at a time.

6. delay allocation.The data block allocation policy of Ext3 is to allocate as soon as possible, while the policy of Ext4 and other modern file operating systems is to delay the allocation as much as possible, data blocks are allocated and written to the disk only after the files are written to the cache. This optimizes the data block allocation of the entire file and significantly improves the performance with the first two features.

7. fast fsck.In the past, the first step of fsck execution was very slow, because it needs to check all inode. now, Ext4 adds a list of inode not used in each group to the inode table, in the future, the fsck Ext4 file system can skip them and only check the inode in use.

8. log verification.Logs are the most common part and can easily lead to disk hardware faults. restoring data from damaged logs will cause more data corruption. The log verification function of Ext4 can easily determine whether the log data is damaged. it also combines the two-phase log mechanism of Ext3 into one phase, which improves the performance while increasing security.

9. No Journaling mode.The log has some overhead. Ext4 allows you to disable the log so that users with special requirements can improve the performance.

10. online fragment.Although delayed allocation, multi-block allocation, and extents can effectively reduce file system fragments, fragments are inevitable. Ext4 supports online fragment and provides the e4defrag tool for fragment of individual files or the entire file system.

11. inode-related features.Ext4 supports a larger inode. compared with the default inode size of 128 bytes in Ext3, Ext4 can accommodate more extended attributes (such as the nanosecond timestamp or inode version) in inode ), by default, the inode size is 256 bytes. Ext4 also supports fast extended attributes and inode reservation ).

12. Persistent preallocation ).In order to ensure sufficient storage space for the downloaded files, P2P software often creates an empty file with the same size as the downloaded file in advance, this prevents downloading failures due to insufficient disk space in the next few hours or days. Ext4 implements persistent pre-allocation at the file system level and provides the corresponding API (posix_fallocate () in libc), which is more efficient than the application software itself.

13. barrier is enabled by default.The disk is equipped with an internal cache to re-adjust the write operation sequence of batch data and optimize the write performance. Therefore, the file system must write the log data to the disk before writing the commit record, if the commit record is written first, and the log may be damaged, data integrity will be affected. In Ext4, barrier is enabled by default. only data before barrier is written to the disk can be written to data after barrier. (You can use the "mount-o barrier = 0" command to disable this feature .)


Related Article

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.