Linux partition Types EXT2, EXT3, EXT4 detailed

Source: Internet
Author: User

First, EXT2 and EXT3

The file system that was used by default in Linux before is Ext2,ext2 file system is really efficient and stable. However, with the application of Linux system in the key business, the weakness of Linux file system is gradually revealed: the Ext2 file system which the system uses by default is a non-log file system. This application in key industries is a deadly weakness. The Ext3 file system is developed directly from the Ext2 file system, and the current Ext3 file system is very stable and reliable. It is fully compatible with the Ext2 file system. The user can smoothly transition to a log-capable file system. This is actually the original design of the ext3 log file system.


Ii. features of the EXT3 log file system

1. High Availability

After the system uses the Ext3 file system, the system does not need to check the file system even after an abnormal shutdown. When the outage occurs, it takes only 10 seconds to recover the ext3 file system.

2. Completeness of data

Ext3 file system can greatly improve the integrity of the file system, and avoid accidental outage of the file system. The Ext3 file system has 2 modes to choose from to ensure data integrity. One of these is the "Keep file system and data consistent" mode. In this way, you will never see junk files stored on disk because of an unhealthy shutdown.

3, the speed of the file system

While using the Ext3 file system, it is sometimes possible to write data multiple times while storing data, but overall, ext3 is better than ext2 performance. This is because the Ext3 log feature optimizes the drive read-write header for the disk. Therefore, the performance of the file system is not degraded compared to the Ext2 file system.

4. Data Conversion

Converting from the Ext2 file system to the Ext3 file system is very easy, as long as you simply type two commands to complete the entire conversion process, users do not have to spend time to back up, restore, format the partition and so on. With a gadget tune2fs provided by a ext3 file system, it can easily convert ext2 file systems to ext3 log file systems. In addition, the Ext3 file system can be loaded directly into the ext2 file system without any changes.

5. Multiple log modes

EXT3 has a variety of logging modes, a mode of operation is to all the file data and metadata (definition of data in the file system, that is, data data) logging (data=journal mode), the other mode of operation is only the metadata log, Instead of logging the data, the so-called data=ordered or Data=writeback mode is not logged. The System Manager can choose between the system's working speed and the consistency of the file data according to the actual work requirement of the system.


Third, the advantages of EXT3

Why do you need to migrate from ext2 to ext3? There are four main reasons for this: availability, data integrity, speed, and ease of migration.

1, the availability of

After a non-normal (power outage, system crash), the Ext2 file system can only be loaded using E2FSCK for consistency checking. The time to run e2fsck depends primarily on the size of the ext2 file system. Verifying a slightly larger file system (dozens of GB) takes a long time. If the number of files on the file system is large, the checksum time is longer. It may take one hours or longer to verify the hundreds of GB file system. This greatly limits availability. In contrast, the ext3 does not require file system validation, even if a hardware failure occurs and the shutdown is not normal. This is because the data is written to disk in a way that the file system always remains consistent. After an abnormally shutdown, the time to recover the ext3 file system does not depend on the size of the file system or the number of files, but on the size of the "log" required to maintain consistency. With the default log settings, the recovery time takes only one second (depending on the hardware speed).

2. Data integrity

With the Ext3 file system, the data integrity can be reliably guaranteed when the shutdown is not normal. You can choose the type and level of data protection. You can choose to ensure that the file system is consistent, but allow data on the file system to be compromised during an unhealthy shutdown, which can increase some speed (but not all) in some situations. You can also choose to keep the reliability of the data consistent with the file system, which means that you will not see any data garbage in the newly written file after the machine. This secure choice of keeping the data reliable and consistent with the file system is the default setting.

3. Speed

Although Ext3 writes data more frequently than ext2, ext3 is often faster than ext2 (high data flow). This is because the ext3 log function optimizes the drive head rotation. You can select 1 of the 3 log modes to optimize speed and selectively sacrifice some data integrity.

4. Easy to migrate

You can enjoy the benefits of a reliable log file system without reformatting the hard drive and easily migrating from ext2 to ext3. Yes, you can experience the benefits of ext3 without having to do long, tedious, and potentially erroneous "backup-reformat-redo" operations. There are two ways to migrate: If you upgrade your system, the Red Hat Linux installer will assist you in the migration process. The job you need to do is to press the Select button for each file system. Use the TUNE2FS program to add log functionality to the existing Ext2 file system. If the file system is already loaded (mount) during the conversion process, the file ". Journal" appears in the root directory, and the file system does not appear if the file system is not mounted. To convert the file system, just run tune2fs–j/dev/hda1 (or any device name where you want to convert the file system), and change the ext2 in the file/etc/fstab to ext3. If you want to convert your own root filesystem, you must use INITRD boot boot. Refer to the MKINITRD manual describing the running program, while confirming that your LILO or grub configuration is loaded with INITRD (if not, the system can still start, but the root filesystem is loaded as ext2 instead of ext3, you can use the command cat/proc/ Mounts to confirm this. Details can be found in the man page online Manual of the TUNE2FS command (executed man tune2fs).

Word

Ext3 log file system is the most simple choice of Linux system from ext2 file system to log file system, and the most concise way to realize it. Since it is developed directly from the Ext2 file system, the system transitions from the Ext2 file system to the Ext3 log file system is smooth and can guarantee the security of the system data. At present, Linux system to use the log file system, the most safe way is to choose the Ext3 file system.


Iv. the main differences 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. 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" (Mballoc Supports a single 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. Enable Barrier 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.) )


Five, EXT2 turn EXT3

Edit /etc/fstab. Change the entries for each partition you want to convert to ext3 to something similar:

  /dev/hdxx/mnt_point ext3 defaults 1 0

In the above row, replace the/dev/hdxx with the component area, such as/DEV/HDA2, and replace the/mnt_point with the location you want to mount, for example:/home. The last 0 guarantees that the partition will not be checked for consistency by the CHECHFS script at boot time. If you want this partition to be able to be mounted and then not sure if the kernel supports EXT3, you can change the ext3 to auto. Start each log of the partition you changed to Ext3 in/etc/fstab, run: tune2fs-j/dev/hdxx re-mount the partition or reboot the system (if you recompile the kernel).

This article is from the "Step Into the Linux World" blog, please be sure to keep this source http://linuxnote.blog.51cto.com/9876511/1642241

Linux partition Types EXT2, EXT3, EXT4 detailed

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.