Tune your ext2/3 filesystem, from Gentoo Weekly Newsletter (October 17th, 2005)

ext2/3 are the main filesystems for a large amount of users but what a lot of people don’t know is that you can get almost Reiser4 speed out of it without any of the instability they’d associated with Reiser4. One of the great features of ext2/3 is the ability to tune it by adjusting various parameters. The one we are going to modify here is dir_index which essentially uses hashed b-trees to speed up lookups in large directories.

Let’s take some precautions, first of all by finding out if some of those parameter are already enabled, by running
# tune2fs -l /dev/hdXX

(replacing XX with your drive and partition your ext2/3 filesystem resides in). If you don’t see dir_index in the list then we can enable it, and just in case you do see dir_index in ‘Filesystem features’ then you have either enabled it already or it was automatically enabled for you.

You are going to need a Gentoo LiveCD because changing parameters on mounted filesystems can cause problems, so in the interest of safety we are booting off the CD. At the start phase the Gentoo install system is booted into what’s called a “ramdisk” which is where the files needed are put into RAM to be used. mke2fs, tune2fs and other parts of the e2fsprogs package will be present at this stage.

Now let’s turn on the feature with
# tune2fs -O dir_index /dev/hdXX

Now run e2fsck with the -D option to have the directories optimized:
# e2fsck -D /dev/hdXX

Do that on any ext2 or ext3 partition and then reboot. You should notice the difference straight away.

Popularity: 9% [?]