Gentoo Wiki



Ext3 Filesystem Tips

Enabling full journaling and directory indexing can speed up your Ext3 filesystem. It's also quite simple to do. This is most easily done while installing, because the filesystem should be unmounted to do this. This article assumes the ext3 partition in question is /dev/hda2. Here's the simple code, the explanation is below.


tune2fs -o journal_data -O has_journal,dir_index /dev/hda2
e2fsck -D /dev/hda2
tune2fs -c 0 -i 0 /dev/hda2

Full Journaling

First, we add the full journaling flag to the ext3 partition.


tune2fs -O has_journal /dev/hda2

Now the partition has full journaling enabled, but it won't be made use of until we make sure the system knows to use it when the partition is mounted.


tune2fs -o journal_data /dev/hda2

There are actually two other ways to do that, but neither is as simple. A reason to use them would be a 2.4.20 kernel or below, which ignore the default mount options on the superblock. The -o option of tune2fs adds default mount options to the partition itself, so you don't need to add them to the mount command. If you didn't do the tune2fs command, you would have to add -o data=journal to your mount command every time you mounted the partition. You could also add data=journal to the mount options column of /etc/fstab. In either case (assuming /dev/hda2 is your root (/) partition), you would also need to add rootflags=data=journal to your kernel parameters in GRUB (or whatever other bootloader you use). Therefore, just using the tune2fs command is easiest as you don't have to worry about any of that.

Note: Full journaling is activated by default on ext3 filesystems (e.g. created with mkfs.ext3). You only need to do this to port older ext2 filesystems to full journaling (i.e. make them ext3)

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's perfectly safe to use, and it provides a fairly substantial improvement in most cases; so it's a good idea to enable it.


tune2fs -O dir_index /dev/hda2

e2fsck -D /dev/hda2

The tune2fs command enables directory indexing, but only for directories created after it is done. The e2fsck command checks updates the directories that are already on the filesystem.

Note: Directory indexing is activated by default in Gentoo via /etc/mke2fs.conf

Remove Excessive Boot-time Checks

With a fully journaled filesystem, it doesn't need to be rechecked every 28 mounts (which is the default). Make sure your /etc/fstab has positive integer at the end of the line where it mounts /dev/hda2 so it checks at boot time. Then we can disable boot-time checks except in cases where it was not cleanly unmounted, where it will automatically check for you.


tune2fs -c 0 -i 0 /dev/hda2

More info

Gentoo forum post discussing the topic

Retrieved from ""

Last modified: Sat, 30 Aug 2008 22:28:00 +0000 Hits: 9,939