Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

3 Answers 3

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

 
discard

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