Saturday, June 6, 2009

Tweaks to Boot Ext4 Filesystem Performance

ext4 performance tweaks
Though the current PCLinuxOS and Mepis support Ext3 filesystem by default, their next versions are going to include ext4. Other leading distributions such as Fedora, Mandriva and Ubuntu have already included ext4.

Like ext3, the default options in ext4 lean more towards security. As a home Linux user you can make a little tradeoff with security/stability to get upto 30% performance boost.

Caution: Please apply all this tricks using a livecd to avoid crashes and filesystem corruption.

Now, get ready for ext4 file system tuning.

1) Change your filesystem to load in writeback mode (default is journal).

Command: tune2fs -o journal_data_writeback /dev/sda1 (change sda1 with your harddrive partition)

2) Edit fstab to change ext4 mounting options.

Command: nano /etc/fstab (change nano with the text editor of your choice)

Change reltime (or whatever option is there) with noatime,data=writeback,barrier=0,nobh
Here is how my fstab entry looks like. Change yours accordingly.

# Entry for /dev/sda1 :
UUID=d1419b8e-1dcc-4b5c-9ce7-182e58d1b1a5 / ext4 noatime,data=writeback,barrier=0,nobh 1 1
# Entry for /dev/sda6 :
UUID=d1a4bcee-a035-4b7c-81db-7129187d83e2 /home ext4 noatime,data=writeback,barrier=0,nobh 1 2
none /proc proc defaults 0 0
# Entry for /dev/sda5 :
UUID=ee29d6ce-1a93-4412-b99b-cd25601c5607 swap swap defaults 0 0

Explanation of mount options:

The default reltime or atime options write readtimes everytimes. It's crazy! Noatime is better options for home desktops.

Default journal mode writes metadata after everytime a file is written. It's safe but demands more disk activity. writeback mode writes metadata lazily after the file is written. It is faster, but may cause the most recent changes to be lost if the system crashes.

Adding barrier=0 and nobh options to fstab entries is little more dangerous. barrier=0 disables the use of write barriers, and nobh tries to avoid associating buffer heads. You can avoid using barrier=0 and nobh options. It gives minor performance boost, the recommended tweak is to use data=writeback in association with noatime. It is the big one!

7 comments:

CARFIELD said...

It work amazing for me

Punaise said...

Nice :) I pushed your article on my own blog, to remember it. Thanks

manmath sahu said...

thanks punaise! you can post as many of my articles as you like, but please place a link to my articles from your blog.

Anonymous said...

It is rather interesting for me to read this post. Thanx for it. I like such topics and anything connected to them. I definitely want to read a bit more on that blog soon.

Laguna Beach Realtor said...

Great article!

web designing said...

Good work keep it up.

Récupération de données said...

I really this tweaks. I hope I will be able to take advantge of them. Thank You.

How about this