What are the mount options to improve ext4 filesystem performance in Linux

The default mount options are deployed usually for maximum performance while maintaining safety for general usage. There are some mount options to optimize ext4 file system according to the needs of the target usage.

barrier=0

This disables the write barriers in Journaling Block Device(JBD). Ext4 file system has barrier=1 by default where ext3 has barrier=0.

Write barriers are used to enforce proper on-disk ordering of journal commits, but they will degrade the performance of the file system. However, if the system does not have battery-backed disks, there is a risk of file system corruption.

data=writeback

By default (data=ordered), all data is forced directly out to the main file system before its metadata (file size, time, owner etc.) being committed to the journal. By changing this option to data=writeback, data ordering will not be preserved, data may be written to the file system after its metadata has been committed to the journal. Only metadata will be journaled.

In order to use this option on the root filesystem, a kernel boot parameter is entered:

rootflags=data=writeback

According to ext4 filesystem documentation on Linux Kernel source, the writeback mode can allow old data to appear in files after a crash and journal recovery. The only supported journaling mode is “data=ordered” which is the default setting.

commit=60

This is the number of seconds for each data and meta data sync. Default setting is 5. In case of a power loss, the last 5 seconds of data stored will be lost, but the file system will not be damaged since journaling is active. Increasing this number to large values will increase performance at a cost of data safety.

Related Post