Chapter 5. The Ext3 File System
-
5.1. Creating an Ext3 File System
-
5.2. Converting to an Ext3 File System
-
5.3. Reverting to an Ext2 File System
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.
It is possible to run
fsck -n
on a live filesystem. However, it will not make any changes and may give misleading results if partially written metadata is encountered.
If LVM is used in the stack, another option is to take an LVM snapshot of the filesystem and run
fsck
on it instead.
Finally, there is the option to remount the filesystem as read only. All pending metadata updates (and writes) are then forced to the disk prior to the remount. This ensures the filesystem is in a consistent state, provided there is no previous corruption. It is now possible to run
fsck -n
.
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.
The only journaling mode in ext3 supported by Red Hat is
data=ordered
(default).
-
Data Integrity
-
The ext3 file system prevents loss of 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. With regard to the state of the file system, ext3 volumes are configured to keep a high level of data consistency by default.
-
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 if the system was to fail.
-
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 5.2, “Converting to an Ext3 File System” for more information on how to perform this task.
The Red Hat Enterprise Linux 6 version of ext3 features the following updates:
Default Inode Sizes Changed
The default size of the on-disk inode has increased for more efficient storage of extended attributes, for example, ACLs or SELinux attributes. Along with this change, the default number of inodes created on a file system of a given size has been decreased. The inode size may be selected with the
mke2fs -I
option or specified in
/etc/mke2fs.conf
to set system wide defaults for
mke2fs
.
If you upgrade to Red Hat Enterprise Linux 6 with the intention of keeping any ext3 file systems intact, there is no need to remake the file system.
New Mount Option:
data_err
A new mount option has been added:
data_err=abort
. This option instructs ext3 to abort the journal if an error occurs in a file data (as opposed to metadata) buffer in
data=ordered
mode. This option is disabled by default (set as
data_err=ignore
).
More Efficient Storage Use
When creating a file system (that is,
mkfs
),
mke2fs
will attempt to "discard" or "trim" blocks not used by the file system metadata. This helps to optimize SSDs or thinly-provisioned storage. To suppress this behavior, use the
mke2fs -K
option.
The following sections cover creating and tuning ext3 partitions. For ext2 partitions, skip the partitioning and formatting sections below and go directly to
Section 5.2, “Converting to an Ext3 File System”.
5.1. Creating an Ext3 File System
After installation, it is sometimes necessary to create a new ext3 file system. For example, if a new disk drive is added to the system, you may want to partition the drive and use the ext3 file system.
The steps for creating an ext3 file system are as follows:
Procedure 5.1. Create an ext3 file system
-
Format the partition with the ext3 file system using
mkfs
.
-
Label the file system using
e2label
.
5.2. Converting to an Ext3 File System
The
tune2fs
command converts an
ext2
file system to
ext3
.
A default installation of Red Hat Enterprise Linux uses ext4 for all file systems. However, to convert ext2 to ext3, always use the
e2fsck
utility to check your file system before and after using
tune2fs
. Before trying to convert ext2 to ext3, back up all file systems in case any errors occur.
In addition, Red Hat recommends creating a new ext3 file system and migrating data to it, instead of converting from ext2 to ext3 whenever possible.
To convert an
ext2
file system to
ext3
, log in as root and type the following command in a terminal:
# tune2fs -j block_device
block_device contains the ext2 file system to be converted.
A valid block device can be one of two types of entries:
-
A mapped device
-
A logical volume in a volume group, for example,
/dev/mapper/VolGroup00-LogVol02
.
-
A static device
-
A traditional storage volume, for example,
/dev/sdbX
, where
sdb is a storage device name and
X is the partition number.
Issue the
df
command to display mounted file systems.
5.3. Reverting to an Ext2 File System
In order to revert to an ext2 file system, use the following procedure.
For simplicity, the sample commands in this section use the following value for the block device:
/dev/mapper/VolGroup00-LogVol02
Procedure 5.2. Revert from ext3 to ext2
-
Unmount the partition by logging in as root and typing:
# umount /dev/mapper/VolGroup00-LogVol02
-
Change the file system type to ext2 by typing the following command:
# tune2fs -O ^has_journal /dev/mapper/VolGroup00-LogVol02
-
Check the partition for errors by typing the following command:
# 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.
If a
.journal
file exists at the root level of the partition, delete it.
To permanently change the partition to ext2, remember to update the
/etc/fstab
file, otherwise it will revert back after booting.