The difference between ext3 and Ext4 file system in Linux

Source: Internet
Author: User
Tags commit data structures
Ext3 or use 15 inode to find blocks of data, the first 12 are direct data blocks, directly to the data block stored data, followed by first-level indirect block, two-level indirect block, three-level indirect block, the following figure:
The point is also a block of data, which is now used to do the index of the block, where the ext3 header file is defined as: __u32 i_block[ext3_n_blocks];/* pointers to BLOCKS * *, so you can calculate the limit of the Ext3 file system:

Maximum partitions:
Because the definition is unsigned 32 digits, the possible location of the block range is 2^32, that is, 4G, if a block size is 4KB, so 4G * 4KB = 16TB

Maximum files:

The front directly points to 12 blocks, and the largest block Size/4,block size is the size of the block, because one index is 4 bytes, so dividing by 4, the total number of blocks that the largest file can use is: + (block SIZE/4) + ( Block SIZE/4) ^2 + (block SIZE/4) ^3, if the block size is 4K, then (12 + 2^10 + 2^20 + 2^30) * 2^12 is approximately equal to 4T.
To break ext3 this size limit, EXT4 uses a 48-bit block index space and uses the following structure instead of the Inode index:
struct Ext3_extent {
__u32 Ee_block; /* Logical block EXTENT covers * *
__u16 Ee_len; /* Number of blocks covered by extent *
__u16 Ee_start_hi; /* High bits of physical block * *
__u32 Ee_start; /* Low bigs of physical block * *
};

So when you look up a block of data, you're not building an index on each block, and using a continuous block of data, which indicates the starting position separately, as well as the number of consecutive blocks, so that in large files, disk IO efficiency and the search block efficiency is greatly improved, so the Ext4 file system is better than ext3. Because of the 48-bit index space, the file system's limit is 2^48 * 4KB = 1EB in the case of 4KB block size, but currently only 16TB partitions are available due to tool limitations.
The main differences between EXT3 and EXT4

Linux Kernel formally supports the new file system EXT4 since 2.6.28. EXT4 is an improved version of EXT3 that modifies some of the important data structures in EXT3, not just as Ext3 to Ext2, but only adds a log function. EXT4 can provide better performance and reliability, as well as richer functionality:
1. Compatible with EXT3. by executing several commands, you can migrate from Ext3 online to EXT4 without reformatting the disk or reinstalling the system. The original EXT3 data structure is still retained, EXT4 action on new data, of course, the entire file system so that the EXT4 is supported by a larger capacity.
2. Larger file systems and larger files. compared to the EXT3 currently supported by the largest 16TB file system and the largest 2TB files, EXT4 supports 1EB (1,048,576TB,1EB=1024PB,1PB=1024TB) file systems, as well as 16TB files.

3. An unlimited number of subdirectories. EXT3 currently supports only 32,000 subdirectories, while EXT4 supports an unlimited number of subdirectories.
4.Extents. EXT3 uses indirect block mapping, which is extremely inefficient when manipulating large files. For example, a 100MB size file, in the EXT3 to create 25,600 blocks (each block size of 4KB) mapping table. And EXT4 introduced the popular extents concept in modern file system, each extent is a set of successive blocks of data, the above file is expressed as "the file data is stored in the next 25,600 blocks", improve a lot of efficiency.
5. Multi-block distribution. when writing data to the Ext3 file system, EXT3 data block allocator can only allocate one 4KB block at a time, write a 100MB file will call 25,600 times the data block allocator, and EXT4 of the multiple-block distributor "Multiblock allocator" (m BALLOC) supports the allocation of multiple blocks of data at one call.
6. Delayed distribution. EXT3 's block allocation strategy is allocated as quickly as possible, while the EXT4 and other modern file operating system strategies are to delay allocation as much as possible until the file is written in cache to begin allocating blocks of data and writing to disk, which optimizes the allocation of data blocks across the entire file. The combination of the first two features can significantly improve performance.
7. Fast fsck. previous fsck First step is slow because it checks all the inode, now EXT4 adds a list of unused inode to the Inode table for each group, so the fsck Ext4 file system can skip them and only check for the inode that is in use. Out.
8. Log check. logging is the most commonly used section and can easily lead to disk hardware failures, while recovering data from corrupted logs can result in more data corruption. The EXT4 log check feature makes it easy to determine whether log data is corrupted, and it merges the EXT3 two-stage logging mechanism into one phase, improving performance while increasing security.
9. "No Log" (no journaling) mode. The log has some overhead, and EXT4 allows logging to be turned off so that some users with special needs can improve performance.
10. Online defragmentation. Although deferred allocations, multiple-block allocations, and extents can effectively reduce file system fragmentation, fragmentation is inevitable. EXT4 supports online defragmentation and will provide e4defrag tools for defragmenting individual files or entire file systems.
11.inode related characteristics. EXT4 supports larger inode sizes, which are 128 bytes larger than the default inode size of EXT3, EXT4 the default inode size is 256 bytes in order to accommodate more extended attributes (such as nanosecond timestamp or inode version) in the Inode. EXT4 also supports fast extended properties (fast extended attributes) and Inode retention (inodes reservation).
12. Persistent pre-distribution (persistent preallocation). Peer-to-peer software to ensure that the download file has enough space to store, often in advance to create an empty file with the same size as the downloaded file, so that in the next few hours or days of insufficient disk space cause download failure. EXT4 implements persistent prefetching at the file system level and provides the appropriate APIs (Posix_fallocate () in libc) that are more efficient than the application software itself.
13. Enable barrier by default. the disk is equipped with an internal cache to readjust the write order of bulk data and optimize write performance, so the file system must write a commit record after the log data has been written to disk, and if the commit record is written first and the log is potentially corrupted, data integrity is affected. EXT4 barrier is enabled by default, the data after barrier can be written only when all the data before barrier is written to disk. (This attribute can be disabled by the Mount-o Barrier=0″ command.) )

After you've looked at two file system demos, you probably know what the difference is between Ext3 and Ext4 in the Linux file system.

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.