Migrate to ext4-general Linux technology-Linux programming and kernel information. The following is a detailed description. Ext4 is widely used in Linux®The latest version in the file system will be as important and popular as the previous version. As a Linux system administrator, you should know the advantages and disadvantages and basic steps of migrating to ext4. This article describes when ext4 should be used, how to use traditional file system maintenance tools in ext4, and how to make full use of the file system.
Ext4 Functions
Linux supports several different file systems. Some of these file systems are dedicated network file systems or file systems developed for other operating systems, but most of them are still used as Linux local file systems-you can (/) and system directory in this file system. Currently, this type of File System includes ext2, ext3, ReiserFS, XFS, and Journaled File System (JFS ). However, file systems are constantly being designed and developed, and new file systems will also be available soon.
The most important Linux file system currently under development is ext4, which is the fourth version of the original extended File System (ext or extfs) specially developed for Linux. Thanks to the previous version, ext4 will likely become an important standard file system for Linux in the near future (probably a standard file system ).
Comparison between Ext4 and ext3
The fourth version of the extended File System (ext or extfs) was generated because developers incorporated new advanced features in ext3. However, there are several problems in the implementation process:
Some new features violate backward compatibility.
The Ext3 code becomes more complex and difficult to maintain.
These changes make the originally very reliable ext3 unreliable.
For these reasons, since September June 2006, developers decided to separate ext4 from ext3 for independent development. The development of Ext4 started from that time, but most Linux users and administrators did not pay much attention to this issue. With the release of the 2.6.19 kernel in November 2006, ext4 was first introduced in the mainstream kernel, but it was still in the trial phase (now), so many people ignored it.
As it is still in the development stage, the function list of ext4 has been changing since the 2.6.24.4 kernel. The current and expected features of Ext4 include those developed from ext3, as shown in table 1.
Table 1. The current and future features of Ext4 surpass ext3
Benefits
A larger file system Ext3 can only accommodate 32 TiB file systems and 2 TiB files. Based on the specific architecture and system settings, the actual capacity limit may be lower than this number-maybe it can only accommodate 2 TiB file systems and 16 giibyte (GiB) files. In contrast, Ext4 has a file system capacity of 1024 pebibyte (PiB) or 1 exbibyte (EiB), while Ext4 has a file capacity of 16 TiB. This may not be important for general desktop computers and servers, but it is important for users of large disk arrays.
Extent is a method to improve the efficiency of disk file descriptors. It can reduce the time required to delete large files.
Persistent pre-allocation if an application needs to be allocated before the disk space is actually used, most file systems allocate data by writing 0 to unused disk space. Ext4 allows allocation in advance, without the need to perform the above operations, which can improve the performance of some databases and multimedia tools.
Latency allocation Ext4 can delay disk space allocation as much as possible, which can improve performance.
More sub-directories if one of the ext3 directories can only contain 32,000 sub-directories and cannot meet your needs, do not worry, because ext4 removes this restriction.
Log checksum Ext4 adds the check and (checksum) functions to log data, which improves the reliability and performance.
Although ext3 is generally not affected by fragmentation, the number of files stored in it may produce fragments. Ext4 supports online disk sorting, which can improve overall performance.
Although this function has not yet been implemented, ext4 supports restoring and deleting files. This function is extremely useful when an object is accidentally deleted.
Faster File System check Ext4 adds a new data structure, allowing fsck to skip unused parts of the disk during the check, thus speeding up the file system check.
Most file systems (including ext3) with a timestamp at the nanosecond level contain timestamp data precise to seconds, while ext4 improves the accuracy to the nanosecond level. Some materials also indicate that the date supported by the timestamp of ext4 is April 25, 2514, while that supported by ext3 is only January 18, 2038.
Because ext4 is still in the development stage, this menu will be changed. Some functions in the function list do not have backward compatibility with ext3 in actual use-that is, they may not be able to mount the ext4 file system using code of the ext3 file system type. However, ext4 retains the forward compatibility-you can mount the ext3 file system just as you mount the ext4 file system.
Use object of ext4
The most significant improvement of Ext4 is the size of the file and file system. Therefore, the users most likely to require ext4 are those whose disk space is several TB. However, the function list in table 1 shows other attractive improvements. For example, if your directory contains a large number of subdirectories or requires that the timestamp accuracy be less than one second, you may want to try to use ext4.
Because ext4 is currently in the experimental stage, you must re-compile the kernel to use it. Otherwise, it will be troublesome to use ext4. In fact, the test phase of ext4 means that it is necessary to use ext4 only when you want to contribute to the development of ext4, or are eager for some of its features. If you want to obtain reliable large disk support before the stable release of ext4, you can consider using XFS or JFS.
Of course, ext4 cannot be in the test phase forever. It will soon become a stable file system. At that time, ext4 will become the best choice for all users like ext3, but several issues need to be noted. First, ext4 still has some unique bugs. Therefore, pay more attention to the first release of the ext4 stable version. Second, using ext4 may cause some earlier tools to be unable to access the disk. This involves the emergency recovery tool, so do not update it before confirming that the tool you are using supports ext4. On the other hand, you should be able to smoothly migrate from ext3 to ext4. If you need to save the existing data, this will achieve easy transfer.
Compile and activate ext4 support
After learning about the content, you may want to experience ext4. However, you must re-compile the kernel and add the necessary support before the experience. I recommend using the latest kernel (the latest version is 2.6.24.4 at the time of writing this article ). Extract the kernel source code and manually set all options or copy the old kernel version. in the config file, enter make oldconfig to copy the previous settings, and then enter the preferred configuration command (such as make xconfig) to view the kernel options. You will see the ext4 option in the main File Systems area, Ext4dev/ext4 extended fs support development (EXPERIMENTAL) (this name may change in the future, especially after the stability of ext4 is announced ). Note: You must check the Prompt for development and/or incomplete code/drivers option in the General region. The ext4 option is also displayed here.
Select ext4 support, save the modifications to the kernel, compile the kernel by entering make, and install the module as root by entering make modules_install. Copy the compiled kernel (in arch/i386/boot or another directory) to the appropriate location (such as/boot) and edit GRand uniied Bootloader (GRUB) or Linux Loader (LILO) to configure and restart the computer. If you are using the start RAM disk, you also need to use the utility mkinitrd during preparation.
In addition to the kernel module, you also need to view a version of e2fsprogs that supports the ext4 file system. You can download a compressed file (links provided in the references section) or use git, as shown in Listing 1.
Listing 1. Get the latest e2fsprogs command through git
$ Git clone git: // git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
$ Cd e2fsprogs
$ Git checkout-B pu
Switched to a new branch "pu"
$ Git branch
Master
* Pu
$ Git pull git: // git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git pu
Note that you may need to use the Package Manager of the release to install git. These tools need to be further tested, so they are not recommended in the production system, and for now, there are not many tools specifically for ext4. Therefore, you may prefer to use the stock e2fsprogs package delivered along with the release.
E2fsprogs compilation process is very standard: Decompress the cd package to the generated directory, input./configure, input make, and input (as root) make install. This process will overwrite the General e2fsprogs package of the release. Therefore, this operation is performed only when you are sure to use the latest (or possibly unstable) version of these tools.
Migrate ext3 to ext4
When the system starts to the kernel with the support of ext4, you can use the new file system. To do this, you must prepare a Redundant Array (RAID) device or other storage space for a partition and independent disk. Then you can use it as the ext4 file system and adjust the file system options.
Prepare a device
To start with simple partitioning, you can use the tool that comes with the new or old e2fsprogs package (mkfs. ext3 or mkfs. ext4) to format partitions or other devices. For example, mkfs. ext4-j/dev/sda6 has prepared/dev/sda6 partitions for use. Mkfs. ext4 can be used to generate a file system and activate many features specific to ext4.
At present, the e2fsprogs program has not completely kept up with the pace of the kernel file system. Fortunately, most kernel drivers do not require special preparation for mkfs. ext4 or other utilities. When a file system is mounted, the ext4 function is activated. If you want to use ext4 on the big media, you must make bold explorations to record and report problems!
If you want to use the existing ext2 or ext3 file system as the ext4 file system, it is not difficult to implement it. Mount the device as described later. However, if you use some new features, such as extent, the file system cannot be used with the ext2 or ext3 driver.
Use ext4
To use a device as an ext4 file system, you must use the ext4dev file system type code to mount it (when ext4 becomes stable, the file system type code will change to ext4 ). For example, mount-t ext4dev/dev/sda6/mnt/point to mount/dev/sda6 to the ext4 File System in/mnt/point. These are the basic usage of ext4. Note that extent is enabled for the default mount option, which makes the file system unavailable when used as an ext3 file system. If you want to try ext4 and return to ext3 at the same time, use the-o noextents option to disable the extent function.
After mounting, you can use ext4 like any other file system: copy a file, directly create a file, and so on. You are not aware of any difference except when you encounter a bug or perform a benchmark test.
Adjust ext4 performance options
You can use the tune2fs program to tune the ext4 file system in the same way as optimizing the ext2 or ext3 file system. Currently, tune2fs does not provide any ext4-specific options, but you can use standard-O parameters to set ext4 options, such as extent.
When the file system is mounted to ext4, the kernel starts to use features specific to the file system, such as extent. The result is that the file system cannot be mounted to the ext3 file system, which at least becomes very difficult.
Although mounting the ext3 File System to ext4 can implement ext4-specific functions, the mounting itself does not convert the old data structure into a new format. For example, existing files are allocated in bulk instead of extent. As a result, old files do not benefit from new features. However, ext4 developers have taken this situation into consideration and provided a solution: the e4defrag tool can be used (in the pilot phase) (which will be introduced later) convert the allocation method to use the extent function. Another new tool (not available) will change the inode size to a new format.
Maintain the ext4 File System
You can use the standard e2fsprogs tool to maintain the ext4 file system. For example, you can use tune2fs to adjust the option after creating the file system, and use fsck. ext4 to perform a file system check. These programs are not significantly different between ext4 and ext3. However, as mentioned above, ext4 includes some enhancements that can improve the performance of fsck.
In addition to these tools, there is a new tool worth noting: e4defrag. This program can fragment disks of mounted ext4 file systems. This can improve performance, especially when the file system space is about to run out. At the same time, this is also conducive to converting the ext2/3 style allocation to the extent-based ext4 style allocation, so it can improve the performance of the file system that used as the ext3 file system. Unfortunately, e4defrag is not part of the standard e2fsprogs package, so you need to download it separately (see the link provided in the references section ).
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