home > linux > optimisation > linux-io-optimisation

Linux IO Optimisation

| 11 Feb 2014

This article shows how to optimise linux for efficient IO. This benefits servers that log heavily or need to write to disk fast.

Including the linux disk scheduler and filesystem mount options.

Linux Scheduler

The io scheduler can be changed dependant on usage of disks and required read write priorities.

The default scheduler in linux is cfq; "Completely Fair Queuing".

I have switched to deadline; (write write write, and forget about a write operation if it took too long), this is useful for logging, but not for somthing like a database.

If you use an ssd check out noop... (simple que, expected to be done fast).

Checking Your Scheduler(s)

You can check what scheduler you are using on a disk with the following;

ls /dev | grep sd | grep -v [0-9] | while read aDisk; do diskSch=$(cat /sys/block/$aDisk/queue/scheduler); echo "$aDisk : $diskSch"; done

which will produce somthing like the following;

sda : [noop] deadline cfq

Changing Your Scheduler(s)

to change the scheduler, echo the name of the scheduler to the same file;

eg; echo deadline > /sys/block/sda/queue/scheduler

repeating the 1st command would produce;

sda : noop [deadline] cfq

to maintain persistance of this setting, you can use a grub config, start up script or the sysfs package. (I use the grub config option).

Mount Options

I use the following mount options with ext3/4 heavy IO mount points like /var;



the errors=remount-ro option simpley will mount the disk in read only mode should it have disk errors;


noatime option tells linux not to update the filesystem with access times on the files, this saves IO and speeds up the machine


data=writeback (usefule for ext filesystems) option tells linux to use writeback mode instead of ordered, this will reduce latency where there are a high nunber of IO operations (logging) however you need to use tune2fs to use this option or you may get disk corruptions. a disadvantage of writeback is that the jornal is updated straight away (if the system crashes the latest files could contain some junk data). This can be cleaned up though.

"nobh" can be used to refrain from using buffer head caches (I've not benchmarked with / without this yet).

and "barrier=0" i've not tested or looked at, disables barrier synchronization and could damage the filesystem if the power is cut.

Mount Options Summary

mount options can be specified in the fstab, but need testing and understanding before applying or benchmarking. You will also need to use tune2fs and e2fsck or fsck to verify the integrity after changes with tune2fs to use the data=writeback method.

Also check that your bios is up to date, and the firmware on your hardisk(s) have been updated.

Post a Comment