Ext3

Related articles
File systems
Ext4
Note
ext3 has been succeeded by
ext4
and should only be used for legacy systems depending on it. If in doubt, always use ext4.
The ext3 filesystem used to be a great choice back when it was added in 2001 due to its introduction of journaling. However,
ext4
should be used instead unless it is required by e.g legacy software. See
Wikipedia:Ext3#ext4
for improvements of ext4 over ext3.
Using tune2fs and e2fsck
Before we begin, we need to make sure you are comfortable with using the tune2fs utility to alter the filesystem options of an ext2 or ext3 partition (or
convert ext2 to ext3
). Please read
tune2fs(8)
.
It is generally a good idea to run a filesystem check using the
e2fsck
utility after you have completed the alterations you wish to make on your filesystem. This will verify that your filesystem is clean and fix it if needed. You should also read the manual page for the
e2fsck
utility if you have not yet done so.
Warning
Only run unmounted!
Make sure any filesystems are cleanly unmounted before altering them with the
tune2fs
or
e2fsck
utilities! Altering or tuning a filesystem while it is mounted can cause severe corruption! Consider booting from a LiveCD such as
Parted Magic
or the Arch Linux one.
Using directory indexing
This feature improves file access in large directories or directories containing many files by using hashed binary trees to store the directory information. It is perfectly safe to use, and it provides a fairly substantial improvement in most cases; so it is a good idea to enable it:
# tune2fs -O dir_index /dev/sd
XY
This will only take effect with directories created on that filesystem after
tune2fs
is run. In order to apply this to currently existing directories, we must run the
e2fsck
utility to optimize and reindex the directories on the filesystem:
# e2fsck -D -f /dev/sd
XY
Note
This should work with ext2, ext3 and ext4 filesystems. Depending on the size of your filesystem, this could take a long time.
Directory indexing is activated by default in Arch Linux via
/etc/mke2fs.conf
.
Enable full journaling
This article or section needs language, wiki syntax or style improvements. See
Help:Style
for reference.
Reason:
First person telling. (Discuss in
Talk:Ext3
)
Warning
ext4
partitions will not mount if both delayed allocation and full journaling (e.g.
journal=data
) are enabled.
By default, ext3 partitions mount with the 'ordered' data mode. In this mode, all data is written to the main filesystem and its metadata is committed to the journal, whose blocks are logically grouped into transactions to decrease disk I/O. This tends to be a good default for most people. However, I have found a method that increases both reliability and performance (in some situations): journaling everything, including the file data itself (known as 'journal' data mode). Normally, one would think that journaling all data would decrease performance, because the data is written to disk twice: once to the journal then later committed to the main filesystem, but this does not seem to be the case. I have enabled it on all nine of my partitions and have only seen a minor performance loss in deleting large files. In fact, doing this can actually improve performance on a filesystem where much reading and writing is to be done simultaneously. See
this article
written by Daniel Robbins on IBM's website for more information.
There are two different ways to activate journal data mode. The first is by adding data=journal as a mount option in /etc/fstab. If you do it this way and want your root filesystem to also use it, you should also pass rootflags=data=journal as a kernel parameter in your
boot loader
configuration. In the second method, you will use tune2fs to modify the default mount options in the file system superblock:
# tune2fs -O has_journal -o journal_data /dev/sd
XY
Please note that the second method may not work for older kernels. Especially Linux 2.4.20 and below will likely disregard the default mount options on the superblock. If you are feeling adventurous you may also want to tweak the journal size. (I have left the journal size at the default.) A larger journal may give you better performance (at the cost of more disk space and longer recovery times). Please be sure to read the relevant section of the tune2fs manual before doing so:
# tune2fs -J size=$SIZE /dev/sd
XY
Disable lengthy boot time checks
Warning
Only do this on a journaling filesystem such as ext3/4. This may or may not work on other journaling filesystems such as ReiserFS or XFS, but has not been tested. Doing so may damage or otherwise corrupt other filesystems. You do this
at your own risk
.
It seems that our ext3 filesystems are still being checked every 30 mounts or so. This is a good default for many because it helps prevent filesystem corruption when you have hardware issues, such as bad IDE/SATA/SCSI cabling, power supply failures, etc. One of the driving forces for creating journaling filesystems was that the filesystem could easily be returned to a consistent state by recovering and replaying the needed journaled transactions. Therefore, we can safely disable these mount-count and time-dependent checks if we are certain the filesystem will be quickly checked to recover the journal if needed to restore filesystem and data consistency. Before you do this please make sure your filesystem entry in
/etc/fstab
has a positive integer in its 6th field (pass) so that it is checked at boot time automatically. You may do so using the following command:
# tune2fs -c 0 -i 0 /dev/sd
XY
If you just want to limit the checks to happen less often without totally disabling them (for peace of mind).  A great method is to change from a number of count's check to a time frame check. See
tune2fs(8)
. Here is once every month:
# tune2fs -c 0 -i 1m /dev/sd
XY
Reclaim reserved filesystem space
Ext3 partition contain a used space of 5% for special reasons by default.  The main reason is to help with less fragmentation on the filesystem.  The other reason for such space is so root can log in even when the filesystem becomes 100% used.  Without this option, the root user might not be able to log in to "clean up" because the system could become unstable, trying to write logs to a 100% full system for example.
The issue with this is that hard drives are getting so big the 5% can add up to be quite a large amount of wasted space. (eg. 100 GB = 5 GB reserved).  Now if you separate your filesystems to like /home for example it might be a good idea to adjust these and reclaim that wasted space on long-term archive partitions (see
this email
for more info).  It is a safe bet to leave your / filesystem at 5% reserved just in case.  Leave reserved space for filesystems containing /var and /tmp also or else you will end up with problems.
Now to change your reserved space to 1% of the drive, which is fair for non-root filesystems.
# tune2fs -m 1 /dev/sdXY
Assigning a label
Once you have created and formatted a partition, you can assign it a label using the e2label command. This allows you to add the partition to
/etc/fstab
using a label instead of using a device path (useful for a USB drive). To add a label to a partition, type the following command as root:
# e2label /dev/sdXY
new-label
If the optional argument
new-label
is not present, e2label will simply display the current filesystem label. If the optional argument
new-label
is present, then e2label will set the filesystem label to be
new-label
q. Ext2 and ext3 filesystem labels can be at most 16 characters long; if new-label  is longer than 16 characters, e2label will truncate it and print a warning message.