Thursday, December 1, 2011

change ext3 journal mode to writeback

There are three mode for ext3 journal:
 1) journal
 2) journal ordered
 3) journal writeback

By default, the linux distribution use 'ordered' mode. However it's better to use 'writeback' mode if there are many system disk IO.

Here is the steps:
 1) edit /etc/fstab, append 'data=writeback'. That will be:
LABEL=/   /    ext3    defaults,data=writeback        1 1

 2) edit /boot/grub/menu.lst, append 'rootflags=data=writeback' in boot option. That will be:
kernel /boot/vmlinuz-2.6.18-243.el5 ro root=LABEL=/ ide0=noprobe rhgb quiet rootflags=data=writeback

 3) IMPORTANT:  adjust tunable filesystem parameters.
tune2fs -o journal_data_writeback /dev/hda1

OK, It's done! reboot the system, use this command to check the result:

    dmesg | grep mode



This message should be there:
...
EXT3-fs: mounted filesystem with writeback data mode.
...

or use tune2fs -l /dev/hda1

if step 3 is missing (actually I did go to the wrong way), the root filesystem maybe read-only. you can remount the root filesystme use this commnad:

    mount -n -o remount /