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).
1 2 |
# cat /sys/block/sda/queue/scheduler noop [deadline] cfq |
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.
1 2 3 |
# echo cfq > /sys/block/sda/queue/scheduler # cat /sys/block/sda/queue/scheduler noop deadline [cfq] |
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.
1 2 3 4 5 6 7 8 |
# cat /sys/block/sda/queue/scheduler noop [deadline] cfq # ls /sys/block/sda/queue/iosched fifo_batch front_merges read_expire write_expire writes_starved |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# cat /sys/block/sda/queue/scheduler noop deadline [cfq] # ls -1 /sys/block/sda/queue/iosched back_seek_max back_seek_penalty fifo_expire_async fifo_expire_sync group_idle low_latency quantum slice_async slice_async_rq slice_idle slice_sync target_latency |