Linux: Change IO Scheduler of Device

Objective: Change the IO scheduler of a disk (or block device) at run time to improve IO performance or throughput.

To get the current IO scheduler for a disk, for example sda, cat the file at /sys/block/<device>/queue/scheduler (change “<device>” to the actual device).

The above indicates that three IO schedulers (noop, deadline, cfq) are available and the deadline scheduler (based on the square brackets) is currently in use.

To set a different scheduler during runtime, for example to use the cfq scheduler for sda, simply use the following syntax.

The above changes will be lost after a reboot. To set a default IO scheduler at boot time, use the kernel boot argument ‘elevator=<scheduler-name>‘. Change “<scheduler-name>” to a supported IO scheduler. In our case, based on the above printouts, it’s either noop, deadline or cfq. IO schedulers are assigned globally at boot time only presently.

As of the Linux 2.6.10 kernel, it is possible to change the IO scheduler for a given block device on the fly (thus making it possible, for instance, to set the cfq scheduler for the system default, but set a specific device to use the deadline or noop schedulers – which can improve that device’s throughput).

Each IO queue / scheduler has a set of IO scheduler tunable parameters associated with it. These parameters control how the IO scheduler works. You can find these entries under /sys/block/<device>/queue/iosched directory. The entries will change based on the selected IO scheduler.

Below are the tunable parameters for deadline and cfq IO schedulers. There are no tunable parameters available for noop IO scheduler.

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, php, python, java, javascript, nodejs, react); plays_on(xbox, ps4); linux_desktop_user(true); }