IO Scheduler: Difference between revisions
(→Set IO Schedulers permanently: cosmetic changes) |
(→Set IO Schedulers permanently: explain which devices are affected by example rule) |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
= Introduction | == Introduction == | ||
The Linux kernel, the core of the operating system, is responsible for controlling disk access by using kernel IO scheduling. | The Linux kernel, the core of the operating system, is responsible for controlling disk access by using kernel IO scheduling. | ||
Line 5: | Line 5: | ||
This article explains how-to change the IO scheduler without recompiling the kernel and without restart. | This article explains how-to change the IO scheduler without recompiling the kernel and without restart. | ||
= Check the currently used IO scheduler | The IO scheduler can be set per block device. In the examples below we will use <code>/dev/sda</code>. | ||
== Check the currently used IO scheduler == | |||
cat /sys/block/sda/queue/scheduler | cat /sys/block/sda/queue/scheduler | ||
[none] mq-deadline bfq | |||
For example the scheduler '''mq-deadline''' delivers best performance on hardware raid and SAN environments. While '''none''' delivers better performance for SSDs. | |||
If you don't see <code>bfq</code> as an option, it means that the kernel module is not loaded. It is still possible to configure the BFQ scheduler however, which will automatically load the kernel module. To load the module manually, use: | |||
modprobe bfq | |||
= | == Switching IO Schedulers on runtime == | ||
Set the scheduler for /dev/sda to Multi-Queue Deadline: | |||
echo mq-deadline > /sys/block/sda/queue/scheduler | |||
Set the scheduler for /dev/sda to BFQ: | |||
echo bfq > /sys/block/sda/queue/scheduler | |||
== Set IO Schedulers permanently == | |||
This can be done via udev rules. For a basic example, the following is a rule to set the BFQ scheduler for all SCSI/SAS/SATA attached disks. Create <code>/etc/udev/rules.d/60-io-scheduler.rules</code> with content: | |||
ACTION=="add|change", KERNEL=="sd[a-z]*", ATTR{queue/scheduler}="bfq" | |||
= Links = | == Links == | ||
* | *https://www.kernel.org/doc/html/v6.8/block/bfq-iosched.html | ||
* | *https://www.kernel.org/doc/html/v6.8/block/blk-mq.html | ||
*https://www.kernel.org/doc/html/v6.8/block/deadline-iosched.html | |||
*https://cromwell-intl.com/open-source/performance-tuning/disks.html | |||
[[Category: HOWTO]][[Category: | [[Category: HOWTO]] [[Category:System Administration]] |
Latest revision as of 13:17, 6 February 2025
Introduction
The Linux kernel, the core of the operating system, is responsible for controlling disk access by using kernel IO scheduling.
This article explains how-to change the IO scheduler without recompiling the kernel and without restart.
The IO scheduler can be set per block device. In the examples below we will use /dev/sda
.
Check the currently used IO scheduler
cat /sys/block/sda/queue/scheduler
[none] mq-deadline bfq
For example the scheduler mq-deadline delivers best performance on hardware raid and SAN environments. While none delivers better performance for SSDs.
If you don't see bfq
as an option, it means that the kernel module is not loaded. It is still possible to configure the BFQ scheduler however, which will automatically load the kernel module. To load the module manually, use:
modprobe bfq
Switching IO Schedulers on runtime
Set the scheduler for /dev/sda to Multi-Queue Deadline:
echo mq-deadline > /sys/block/sda/queue/scheduler
Set the scheduler for /dev/sda to BFQ:
echo bfq > /sys/block/sda/queue/scheduler
Set IO Schedulers permanently
This can be done via udev rules. For a basic example, the following is a rule to set the BFQ scheduler for all SCSI/SAS/SATA attached disks. Create /etc/udev/rules.d/60-io-scheduler.rules
with content:
ACTION=="add|change", KERNEL=="sd[a-z]*", ATTR{queue/scheduler}="bfq"