Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can the Linux disk scheduler be changed on the fly by writing to /sys/block/sda/queue/scheduler? Should applications (e.g. Mysql) be stopped / started when changing?

share|improve this question

migrated from stackoverflow.com Jan 24 '12 at 0:18

This question came from our site for professional and enthusiast programmers.

up vote 3 down vote accepted

You can change the IO scheduler on the fly without fear. It is protected by appropriate locking to make sure no transactions are lost.

share|improve this answer

Yes you can, and no, applications do not need to be stopped/started. This is by design, so that you can (relatively) safely try out different ones on a production system without downtime.

It does cause a "hiccup"; IOs in progress are allowed to complete, and new IO requests are blocked until the new scheduler is instated.

You can also have a different IO scheduler per block device (as seen by the kernel e.g. /dev/sda).

share|improve this answer
  1. You could add an echo deadline > /sys/block/sda/queue/scheduler (as example) at the start of application and another echo at the end with the initial scheduler .. echo cfq > /sys/block/sda/queue/scheduler

  2. You can make a cron script that verifies the application start and change the scheduler accordingly.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.