2008-01-27

Tuning ext3 for performance without losing its data integrity potential

Ext3 as the by journaling capability enhanced successor filesystem of ext2 has quite conservative default parameters which ensure an adequate data integrity after crashes. But if you make backups and using a notebook you will maybe pay a greater attention to the read/write speed of your HDD than an exaggerated and performance wasting data integrity. In the following you can see the settings which I am using for my LUKS encrypted partitions accommodated by a LVM. You have to alter the both files below as followed:

/boot/grub/menu.lst

#[...]
title Ubuntu 7.10, kernel 2.6.22-14-generic
root (hd0,1)
kernel /vmlinuz-2.6.22-14-generic root=/dev/mapper/vg-starlight ro rootflags=data=writeback,nobh,commit=100 splash usbcore.autosuspend=1
initrd /initrd.img-2.6.22-14-generic
quiet


/etc/fstab

#[...]
/dev/mapper/swap none swap sw 0 0
/dev/sda2 /boot ext3 noatime,nobh,data=writeback,commit=100 1 2
/dev/mapper/vg-starlight / ext3 noatime,nobh,data=writeback,commit=100 0 1
/dev/mapper/home /home ext3 noatime,nobh,data=writeback,commit=100 0 2
/dev/mapper/tmp /tmp ext3 noatime,nobh,data=writeback,commit=100 0 0


In this way you can tune the I/O performance of ext3 partitions by

  • disabling file access time logging (noatime)

  • increasing the commit interval which is responsible for writing data on the HDD (commit) to 100 seconds

  • not attaching buffer_heads to file pagecache (nobh)

  • not preserving data ordering; so data may be written into the main file system after its metadata has been committed to the journal which is the highest throughput option (data=writeback)


Due to LVM and encryption (accomplished by cryptsetup) I operate in my /etc/fstab with mapped devices. But these mapped devices can be normal block devices (like /dev/hda2, /dev/sda1 etc.) as well. Finally you should not forget to add the corresponding parameters during the system boot-up by passing them to the kernel in /boot/grub/menu.lst.

Note:
You also may be interested in how to tune ext4 for performance or how to use a swap file instead of a swap partition.