• Aucun résultat trouvé

The ext3 File System

Part II. File Systems

Chapter 6. The ext3 File System

The default file system is the journaling ext3 file system.

6.1. Features of ext3

The ext3 file system is essentially an enhanced version of the ext2 file system. These improvements provide the following advantages:

Availability

After an unexpected power failure or system crash (also called an unclean system shutdown), each mounted ext2 file system on the machine must be checked for consistency by the e2fsck program. This is a time-consuming process that can delay system boot time significantly, especially with large volumes containing a large number of files. During this time, any data on the volumes is unreachable.

The journaling provided by the ext3 file system means that this sort of file system check is no longer necessary after an unclean system shutdown. The only time a consistency check occurs using ext3 is in certain rare hardware failure cases, such as hard drive failures. The time to recover an ext3 file system after an unclean system shutdown does not depend on the size of the file system or the number of files; rather, it depends on the size of the journal used to maintain consistency. The default journal size takes about a second to recover, depending on the speed of the hardware.

Data Integrity

The ext3 file system provides stronger data integrity in the event that an unclean system shutdown occurs. The ext3 file system allows you to choose the type and level of protection that your data receives. By default, the ext3 volumes are configured to keep a high level of data consistency with regard to the state of the file system.

Speed

Despite writing some data more than once, ext3 has a higher throughput in most cases than ext2 because ext3's journaling optimizes hard drive head motion. You can choose from three journaling modes to optimize speed, but doing so means trade-offs in regards to data integrity.

Easy Transition

It is easy to migrate from ext2 to ext3 and gain the benefits of a robust journaling file system without reformatting. Refer to Section 6.3, “Converting to an ext3 File System” for more on how to perform this task.

The following sections walk you through the steps for creating and tuning ext3 partitions. For ext2 partitions, skip the partitioning and formating sections below and go directly to Section 6.3, “Converting to an ext3 File System”.

6.2. Creating an ext3 File System

After installation, it is sometimes necessary to create a new ext3 file system. For example, if you add a new disk drive to the system, you may want to partition the drive and use the ext3 file system.

1. Create the partition using parted or fdisk.

2. Format the partition with the ext3 file system using m kfs.

3. Label the partition using e2label. 4. Create the mount point.

5. Add the partition to the /etc/fstab file.

6.3. Converting to an ext3 File System

The tune2fs program can add a journal to an existing ext2 file system without altering the data already on the partition. If the file system is already mounted while it is being transitioned, the journal is visible as the file .journal in the root directory of the file system. If the file system is not mounted, the journal is hidden and does not appear in the file system at all.

Note

A default installation of Red Hat Enterprise Linux uses ext3 for all file systems.

To convert an ext2 file system to ext3, log in as root and type, /sbin/tune2fs -j <file_system>

where <file_system> is an appropriate LVM2 file system.

A valid LVM2 file system could be one of two types of entries:

A mapped device — A logical volume in a volume group, for example, /dev/m apper/VolGroup00-LogVol02.

A static device — A traditional storage volume, for example, /dev/hdbX, where hdb is a storage device name and X is the partition number.

Issue the df command to display mounted file systems. For more detailed information on the LVM file system, refer to Chapter 8, LVM Configuration.

For the remainder of this section, the sample commands use the following value:

/dev/mapper/VolGroup00-LogVol02

After doing this, be certain to change the partition type from ext2 to ext3 in the /etc/fstab file.

If you are transitioning your root file system, you must use an initrd image (or RAM disk) to boot. To create this, run the m kinitrd program. For information on using the m kinitrd command, type m an m kinitrd. Also, make sure your GRUB configuration loads the initrd.

If you fail to make this change, the system still boots, but the file system is mounted as ext2 instead of ext3.

6.4. Reverting to an ext2 File System

Because ext3 is relatively new, some disk utilities do not yet support it. For example, you may need to

shrink a partition with resize2fs, which does not yet support ext3. In this situation, it may be necessary to temporarily revert a file system to ext2.

To revert a partition, you must first unmount the partition by logging in as root and typing, umount /dev/mapper/VolGroup00-LogVol02

Next, change the file system type to ext2 by typing the following command as root:

/sbin/tune2fs -O ^has_journal /dev/mapper/VolGroup00-LogVol02

Check the partition for errors by typing the following command as root:

/sbin/e2fsck -y /dev/mapper/VolGroup00-LogVol02

Then mount the partition again as ext2 file system by typing:

mount -t ext2 /dev/mapper/VolGroup00-LogVol02/mount/point

In the above command, replace /mount/point with the mount point of the partition.

Next, remove the .journal file at the root level of the partition by changing to the directory where it is mounted and typing:

rm -f .journal

You now have an ext2 partition.

If you want to permanently change the partition to ext2, remember to update the /etc/fstab file.

Tip

You can increase the size of an ext3 file system using ext2online. ext2online allows you to increase the size of an ext3 file system once it is mounted (online) and on a resizable logical volume. The root file system is set up by default on LVM2 logical volumes during installation.

Note that ext2online will only work on ext3 file systems. For more information, refer to m an ext2online.