Main differences between CentOS File System ext3 and ext4

Source: Internet
Author: User

Main differences between CentOS File System ext3 and ext4

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 .)


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.