Linux ext2 ext3 ext4 comparison __linux

Source: Internet
Author: User
Tags commit
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. EXT4 supports 1EB (1,048,576TB, 1EB=1024PB, 1PB=1024TB) file systems, as well as 16TB files, 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, 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 the data is written to the Ext3 file system, the EXT3 data block allocator can allocate only one 4KB block at a time, and a 100MB file will call 25,600 times the data block allocator, while EXT4 multiple splitter "Multiblock allocator" (Mballoc Supports the allocation of multiple blocks of data at one time.

6. Delayed distribution. EXT3 's data block allocation strategy is distributed as soon as possible, the strategy of EXT4 and other modern file operating systems is to delay allocation as much as possible until the file is written in cache to begin allocating blocks of data and writing to disk, thus optimizing the allocation of chunks of the entire file, which can significantly improve performance with the first two features.

7. Fast fsck. It is slow to perform the first step of fsck, because it checks all the inode, now EXT4 adds a list of unused inode to the Inode table for each group, and the fsck EXT4 file system can skip over them and check out the inode that is in use.

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.

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


Ext2 and Ext3

The Linux ext2/ext3 file system uses index nodes to log file information, acting like a Windows file allocation table. An index node is a structure that contains information about the length of a file, the time it was created and modified, the permissions, the affiliation, and the location on the disk. A file system maintains an array of index nodes, each of which corresponds to the only element in an array of indexed nodes. The system assigns a number to each index node, which is the index number of the node in the array, called the index node number. The Linux file system keeps the file index node number and filename in the directory at the same time. So, the directory simply combines the name of the file with its index node number, which is called a connection for each file name and index node in the table of contents. For a file, there is a unique index node number corresponding to it, for an index node number, but can have more than one file name corresponding to it. Therefore, the same file on the disk can be accessed through a different path.
The file system used by default before Linux is Ext2,ext2 file system is indeed efficient and stable. However, with the Linux system in the key business applications, the weakness of the Linux file system is gradually revealed: the system defaults to use the Ext2 file system is not a log file system. This application in key industries is a fatal weakness. This article introduces you to Linux using the ext3 log file system application.
EXT3 file system is directly from the Ext2 file system development, the current EXT3 file system has been very stable and reliable. It is fully compatible with the Ext2 file system. The user can transition smoothly to a log-capable file system. This is actually the original design of the ext3 log file system.

Features of the EXT3 log file system
1. High Availability
After the system has used the Ext3 file system, the system does not need to check the file system even after the shutdown is abnormal. After the outage occurs, it takes only 10 seconds to recover the ext3 file system.
2, the integrity of the data:
Ext3 file system can greatly improve the integrity of the file system and avoid the accidental downtime of the file system damage. There are 2 modes of ext3 file systems to choose from to ensure data integrity. One of these is the "Keep file system and data consistency" mode. In this way, you will never see the junk files that are stored on disk because of an abnormal shutdown.
3, the speed of the file system:
While using the Ext3 file system, it is sometimes possible to write data more than once while storing the data, but overall, ext3 is better than ext2 performance. This is because the ext3 log function optimizes the drive read-write headers of the disk. Therefore, the performance of the file system is not reduced compared to the Ext2 file system.
4. Data Conversion
It is easy to convert from Ext2 file system to ext3 file system, as long as you simply type two commands to complete the conversion process, users do not have to spend time to back up, restore, format partitions, and so on. With a small tool provided by a ext3 file system TUNE2FS, it can easily convert ext2 file system to ext3 log file system. In addition, the Ext3 file system can be loaded directly into the ext2 file system without any changes.
5, a variety of log mode
EXT3 has a variety of logging modes, a mode of operation is to log all file data and metadata (the data that defines the data in the file system, that is, the data) (data=journal mode), and the other mode of work is to record only the metadata log. Instead of logging data, the so-called data=ordered or Data=writeback mode. System managers can choose between the working speed of the system and the consistency of the file data according to the actual work requirements of the system.

With SSD hard drive testing, the test results show that the Intel SSD is incredibly fast to read and write, it also shows that all aspects of EXT4 performance are more than the previous generation Ext3, and even in most cases, a lot faster than the EXT2 without the log function.

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.