Convert the file system from ext2 to ext3

Source: Internet
Author: User
Convert the file system from ext2 to ext3-general Linux technology-Linux technology and application information. For more information, see the following. (Statement: This article is for personal use only. The copyright belongs to the author of the article)

The log file system ext3 has the characteristics and advantages that ext2 does not possess. The smooth transformation from ext2 to ext3 is the only way to achieve the ext3 advantage. The ext3 file system is a higher-level version of The ext2 file system. It has a unique advantage not available in other similar log file systems-fully compatible with the ext2 file system, therefore, ext3 can make full use of existing operations and Applications in ext2, and is more effective and easier to use than ext2. It adds the log feature for recording metadata on the basis of ext2, and is a log that supports asynchronous processing. Red Hat 7.2 and SuSE 7.3 have released Linux systems that contain ext3 file systems. By using the latest Linux installation version and e2fsprogs Linux utilities, You can compile the ext3 file system into the system kernel. This section describes some basic methods for converting ext2 to ext3 systems and provides users with suggestions for correction.

Ext3 Log File System

1. Log File System
The log file system is designed to track changes in the file system rather than the content of the file system. It uses independent log files to track changes in disk content, just like relational databases (RDBMS). Therefore, it is safer than traditional file systems. The log file system can commit or Cancel Changes to the file system by means of transaction processing. When the system is shut down abnormally and the file system is unmounted abnormally while writing data to the disk, the file system will be in an inconsistent state. To minimize File System inconsistencies and shorten the startup time of the operating system, the file system needs to track records that cause system changes. These records are stored in a separate location from the file system, it is usually called "log ". Once these logs are securely written, the log file system can apply them to the file system to clear the records that cause system changes, and make them into a set that causes changes to the file system.

The main function of a log file is to ensure the consistency of the file system to the maximum extent. Generally, the file system stores the log records. When the computer is restarted, the installer checks the log records to ensure the consistency of the file system, and securely and completely apply it to the file system. In most cases, the operating system does not check the consistency of the file system. The computer that uses the log file system immediately uses log detection after the system boot to reduce the possibility of data loss.

2. ext3
The ext3 file system is a log file and 100% compatible with the ext2 file system. The main difference between the ext2 file system and ext2 file system is its rapid file storage update. When a computer reads or writes data from a disk, it must ensure the consistency of files and directories in the file system. Data in all log files is stored in the storage device in the form of data blocks. When a disk partition is created, the file system supports data storage and data organization by file and directory.

Like ext2, ext3 is jointly developed by developers from multiple vendors. Its development does not depend on any individual or organization. It provides and uses a general log layer generic journaling layer (jbd ). This layer can be used in other environments, in file systems, and on other devices. Now the NVRAM device supported by Linux is supported by ext3. When the file system crashes due to software or hardware errors, the file repair program e2fsck is very successful in data restoration. ext3 uses the same code as e2fsck to fix the crashed file system, therefore, when data crashes, ext3 has the same advantages as ext2 to prevent data loss.

It is worth noting that none of the above advantages is ext3 exclusive, and most of the other file systems are also ext3, but ext3 is sufficient, this is also the comprehensive advantage of ext3. Ext3 is the most satisfying log file system.

Conversion from ext2 to ext3

1. Conversion
To convert an ext2 file system to an ext3 file system, you can add a log file to an existing ext2 file system. To convert the original/back (/dev/hda5) File System from the ext2 File System to the ext3 file system, follow these steps (we recommend that you back up the file system before converting the system ):

(1) uninstall/back directory

Run the following command:
Umount/back

(2) Conversion

The command format is as follows:
/Sbin/tune2fs-j

For example, to convert the partition/dev/hda5 ext2 system to the ext3 file system, run the following command:

/Sbin/tune2fs-j/dev/hda5

Here, tune2fs is the conversion command, and the-j option indicates the ext3 log created on the existing ext2 file system.

(3) installation/back directory

Run the following command:
Mount-text3/dev/hda5/back

After the command is executed, the system will create a log file. If the file system has been mounted during the conversion process, ". journal File. Otherwise, the log file does not exist.

(4) modify the/etc/fstab file

For example, you can use the "auto" option to update the/etc/fstab Boot Record immediately after converting the ext2 Log File System to the ext3 log file system.

Before conversion:
/Dev/hda5/opt ext2 defaults 1 2

After conversion:
/Dev/hda5/opt ext3 defaults 1 0

The last field/etc/fstab in Linux is set for the boot system, and the "fsck (file system check)" program checks the consistency of the file system, at the same time, change the ext2 in the/etc/fstab file to ext3. When the ext3 file system is used, this field can be set to "0 ". This means that the fsck program will not check the consistency of the file system, and the consistency of the file system will be ensured by the subsequent logs. If you want to switch to a boot system, you must use initrd to start the system, run mkinitrd, follow the steps described in its Manual, and check whether initrd is mounted in the LILO or Grub configuration. If the ext3 conversion fails, the system can still start, but the boot system will load it in the form of ext2 instead of ext3. You can use the command cat/proc/mount to confirm this.

Run the following command:
Mount

It can be displayed as follows:
/Dev/hda5 on/test type ext3 (rw)

This indicates that the system has successfully switched from ext2 to ext3.

2. New
Upgrade an existing ext2 instance and use tune2fs. To create a new ext3 file system, use the mke2fs command in the installed e2fsprogs package to add the-f parameter. This allows you to create a new ext3 file system. Assume that you want to create/dev/hda5 as an ext3 file system. The procedure is as follows:

(1) Create

Run the following command:
Mke2fs-j/dev/hda5

(2) installation/back directory

Run the following command:
Mount-t ext3/dev/hda5/back

(3) modify the/etc/fstab file

E2fsck in the new e2fsprogs supports ext3. When an ext3 file system is damaged, uninstall the device and use e2fsck to fix it.

Run the following command:
Umount/back

E2fsck-fy/dev/hda5

When the system is restarted, it usually takes some time to check the log file system. Use ext3 to avoid file system checks that take a long time to restart. For example, use the following command:

Tune2fs-I 0-c 0/dev/hda4

You can disable the file system check.

If you want to return ext2 from ext3, the method is also very simple, that is, uninstall ext3 and reinstall ext2, the command is as follows:

Mount-text2/dev/hda5/test

Of course, to install ext2 during startup, you must reset it in the etc/fstab file.

3. Correction
Ext3 also has its disadvantages. Its biggest drawback is that it does not have the high performance that modern file systems can improve file data processing speed and relieve pressure. Red Hat Linux 8.0.94 Release Notes also pointed out some issues of ext3. If a file system is created in beta, we recommend that you delete all traces of the HTree index function from each file system. First, use the following command:

Tune2fs-O ^ dir_index/dev/

Then you can use the following command to delete the index from the directory:

E2fsck-fD/dev/

Conclusion
Linux is an excellent Member of the operating system family and the fastest growing number of users in recent years. As the basic file system of all Linux releases, the ext2 file system is responsible for file management, access, sharing and protection for the operating system and users. It not only facilitates security, but also effectively improves the utilization of system resources. In Red Hat Linux 7.2, Red Hat adopted the log file system ext3 for the first time. As the first officially supported log file system, it is undoubtedly fully compatible with ext2's high-performance file system. Its compatibility includes all other applications used on ext2 file systems. The upgrade from ext2 to ext3 is simple, and ext3 improves the performance of the Linux system and solves the inconsistency problem in the system. Ext3 file system is an excellent and promising 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.