For a long time, ext3 is the default file system for many Linux distributions, and now Ext4 has been released, and a distribution has started to use EXT4 as the default file system (in fact Ext4 was originally an extension of ext3, but to ensure ext3 stability, Many people are opposed to extending the ext3 directly, so they are alone as a EXT4 project).
Ext3 still uses 15 inode to find the data block, the first 12 is the direct data block, directly points to the data block that stores the data, then the second level indirect block, two level indirect block, three level indirect block, for example:
650) this.width=650; "class=" Fit-image "border=" 0 "src=" http://images.51cto.com/files/uploadimg/20120508/1058140. PNG "style=" border:0px;text-align:center; "/>
Where point is also a block of data is now used to do the index of the data 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 partition:
Since the definition of unsigned 32-bit number, it is possible to locate the block range of 2^32, that is, 4G, if a block size of 4KB, so 4G * 4KB = 16TB
Max file:
The front directly points to 12 data blocks, the first level of indirect block is the maximum block size/4,block size, because an index is 4 bytes, so divided by 4, so calculate, the largest file can be used by the total number of blocks: + (block SIZE/4) + ( Block SIZE/4) ^2 + (block SIZE/4) ^3, if block size is 4K, then (12 + 2^10 + 2^20 + 2^30) * 2^12 is approximately equal to 4T.
To break the size limit of ext3, Ext4 uses a 48-bit block index space and uses the following structure instead of the Inode index:
struct Ext3_extent {
__u32 Ee_block; /* First 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 */
};
In this way, it is not necessary to create an index for each block, and to use contiguous blocks of data, that is, to indicate the starting position, and the number of consecutive blocks, so that the disk IO efficiency and the lookup block efficiency are greatly improved in large files, so the EXT4 filesystem is also better than ext3. Because the 48-bit index space is used, the file system limit is 2^48 * 4KB = 1EB at 4KB block size, however, there are currently only 16TB partitions available due to the limitations of the tool.
The main difference between EXT3 and EXT4
Linux Kernel officially 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 adds a log function. The EXT4 offers better performance and reliability, as well as a richer range of features:
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 has thus obtained the EXT4 supported by the larger capacity.
2. Larger file systems and larger files. EXT4 supports 1EB (1,048,576TB,1EB=1024PB,1PB=1024TB) file systems and 16TB files, respectively, compared to the maximum 16TB file system and maximum 2TB files currently supported by EXT3.
3. An unlimited number of subdirectories. EXT3 currently supports only 32,000 subdirectories, and EXT4 supports an unlimited number of subdirectories.
4.Extents. EXT3 uses indirect block mapping, which is extremely inefficient when working with large files. For example, a 100MB size file, in Ext3 to create 25,600 blocks (each data block size is 4KB) mapping table. The EXT4 introduces the popular extents concept in modern file systems, each extent a contiguous set of data blocks, which is expressed as "the file data is stored in the next 25,600 blocks", which improves a lot of efficiency.
5. Multi-block allocation. When writing data to the Ext3 file system, the EXT3 data block allocator can only allocate a 4KB block at a time, write a 100MB file will call 25,600 data block allocator, and Ext4 's multi-block allocator "Multiblock Allocator" (Mballo c) supports one call to allocate multiple blocks of data.
6. Deferred distribution. EXT3 's block allocation strategy is allocated as quickly as possible, while the EXT4 and other modern file operating system policies are to delay allocations as much as they can, until the file is written in the cache before the data block is allocated and written to disk, which optimizes the data block allocation for the entire file, which, together with the first two features, significantly improves performance.
7. Fast fsck. The first step in executing fsck is slow, because it checks all the inode, and now EXT4 adds a list of unused inode to each group's inode table, and the fsck EXT4 file system will be able to skip them in the future to check only the inode that is in use.
8. Log check. Logs are the most common part and are prone to disk hardware failure, and recovering data from corrupted logs can result in more data corruption. EXT4 's log check function makes it easy to tell if the log data is corrupted, and it merges the EXT3 two-stage logging mechanism into one phase, increasing security while improving performance.
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 delayed allocations, multiple allocations, and extents can effectively reduce file system fragmentation, fragmentation is unavoidable. EXT4 supports online defragmentation and will provide e4defrag tools to defragment individual files or the entire file system.
11.inode related features. The EXT4 supports larger inode sizes, compared to the default inode size of Ext3 of 128 bytes, EXT4 in order to accommodate more extended attributes (such as nanosecond timestamp or inode version) in the Inode, the default inode size is 256 bytes. EXT4 also supports fast extended properties (fast extended attributes) and Inode retention (inodes reservation).
12. Persistent pre-allocation (persistent preallocation). To ensure that the downloaded file has enough space to store, it is often pre-created an empty file with the same size as the downloaded file, so that the download fails due to insufficient disk space in the next few hours or days. The EXT4 implements durable pre-allocation at the filesystem level and provides the appropriate 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 order of the bulk data, optimizing write performance, so the file system must write the commit record after the log data is written to disk, and if the commit record is written earlier and the log is potentially corrupted, data integrity is affected. EXT4 By default, barrier is enabled, and data after barrier can be written only if the data before barrier is written to disk. (This attribute can be disabled by the Mount-o Barrier=0″ command.) )
650) this.width=650; "class=" Fit-image "border=" 0 "src=" http://images.51cto.com/files/uploadimg/20120508/1058141. JPG "width=" 498 "style=" border:0px;text-align:center; "/>
The main difference between Linux file system ext3 and EXT4