Linux Change The I/O Scheduler For A Hard Disk

by on June 9, 2008 · 7 comments· LAST UPDATED December 21, 2009

in , ,

How do I change the I/O scheduler for a particular hard disk without rebooting my Linux server system?

CFQ [cfq] (Completely Fair Queuing) is an I/O scheduler for the Linux kernel and default under many Linux distributions.

Noop scheduler (noop) is the simplest I/O scheduler for the Linux kernel based upon FIFO queue concept.

Anticipatory scheduler (anticipatory) is an algorithm for scheduling hard disk input/output as well as old scheduler which is replaced by CFQ

Deadline scheduler (deadline) - it attempt to guarantee a start service time for a request.

Task: View Current Disk scheduler

Assuming that your disk name /dev/sda, type:
# cat /sys/block/{DEVICE-NAME}/queue/scheduler
# cat /sys/block/sda/queue/scheduler

Sample output:

noop anticipatory deadline [cfq]

Task: Set I/O Scheduler For A Hard Disk

To set a specific scheduler, simply type the command as follows:
# echo {SCHEDULER-NAME} > /sys/block/{DEVICE-NAME}/queue/scheduler
For example, set noop scheduler, enter:
# echo noop > /sys/block/hda/queue/scheduler

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 7 comments… read them below or add one }

1 marco September 24, 2008 at 3:41 pm

How do i change the scheduler in general?

Reply

2 newbie October 17, 2008 at 10:21 am

Edit /boot/grub/grub.conf and enter in kernel line elevator=noop or any other scheduler available.

Kernel compilation should also be a way I think.?.

http://www.redhat.com/magazine/008jun05/features/schedulers/

Greetz

Reply

3 marco October 17, 2008 at 3:57 pm

Thank you newbie. :)

Reply

4 Ratnadeep Joshi November 6, 2009 at 8:43 am

You can echo to /sys/block//queue/scheduler/

e.g. If you want the scheduler to be ‘noop’ for ‘sda’, you should run:
# echo noop > /sys/block/sda/queue/scheduler

Reply

5 Danny December 29, 2009 at 6:24 am

“But I’m on Ubuntu, and I want to do it without enabling the root account or running sudo su -:
echo anticipatory | sudo tee /sys/block/sdb/queue/scheduler

Also note that, if you’re using lvm, you’ll have the physical devices (like sda) as well as the virtual devices (like dm-1). Same goes for software raid – you’ll have md0, etc. It’s unclear to me which setting wins if you are running lvm on top of software raid (which isn’t incredibly uncommon), and have different schedulers set for the physical disks, raid devices, and lvm devices…

PS: it looks like you can find out which LVM volume maps to “dm-6″, for example, by dong an ls -l on /dev/block/252:*. On one of my machines, I get

lrwxrwxrwx 1 root root 18 2009-12-12 21:53 /dev/block/252:6 -> ../mapper/pyro-var

Which indicates that dm-6 is currently the "var" volume in the "pyro" volume group.

Reply

6 sreenath s September 5, 2010 at 6:20 pm

How to change the linux scheduler for user fairness ???

Reply

7 Kedar March 27, 2014 at 6:56 am

I cant find device name of my attached device in /sys/block/ since its attached external drive. Therefore I cant see current io-scheduler for this disk.
Please help.

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , ,

Previous Faq:

Next Faq: