IO Scheduler: Difference between revisions

From Proxmox VE
Jump to navigation Jump to search
m (changed default scheduling sentence)
(Update article for current kernels)
Line 9: Line 9:
  cat /sys/block/sda/queue/scheduler
  cat /sys/block/sda/queue/scheduler


  noop anticipatory [deadline] cfq
  [none] mq-deadline bfq


For example the scheduler '''deadline''' delivers best performance on hardware raid and SAN environments. While '''noop''' delivers better performance for SSDs.
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 ==
== Switching IO Schedulers on runtime ==


Set the scheduler for /dev/sda to Deadline:  
Set the scheduler for /dev/sda to Multi-Queue Deadline:  


  echo deadline > /sys/block/sda/queue/scheduler
  echo mq-deadline > /sys/block/sda/queue/scheduler


Set the scheduler for /dev/sda to CFQ:  
Set the scheduler for /dev/sda to BFQ:


  echo cfq > /sys/block/sda/queue/scheduler
  echo bfq > /sys/block/sda/queue/scheduler


== Set IO Schedulers permanently ==
== Set IO Schedulers permanently ==


In order to choose a new default scheduler you need to add the following into your /etc/default/grub:
This can be done via udev rules. For a basic example, create <code>/etc/udev/rules.d/60-io-scheduler.rules</code> with content:
 
nano /etc/default/grub
 
GRUB_CMDLINE_LINUX_DEFAULT="... elevator=deadline"
 
or:
 
GRUB_CMDLINE_LINUX_DEFAULT="... elevator=cfq"
 
After you change /etc/default/grub you need to run update-grub to apply changes:


  update-grub
  ACTION=="add|change", KERNEL=="sd[a-z]*", ATTR{queue/scheduler}="bfq"


== Links ==
== Links ==
*http://en.wikipedia.org/wiki/Deadline_scheduler
*https://www.kernel.org/doc/html/v6.8/block/bfq-iosched.html
*http://en.wikipedia.org/wiki/CFQ
*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
*https://cromwell-intl.com/open-source/performance-tuning/disks.html


[[Category: HOWTO]] [[Category:System Administration]]
[[Category: HOWTO]] [[Category:System Administration]]

Revision as of 11:56, 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.

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, create /etc/udev/rules.d/60-io-scheduler.rules with content:

ACTION=="add|change", KERNEL=="sd[a-z]*", ATTR{queue/scheduler}="bfq"

Links