≡ Menu

Linux Change The I/O Scheduler For A Hard Disk

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

Share this tutorial on:

Like this? Follow us on Twitter OR support us by using Patreon

{ 12 comments… add one }
  • marco September 24, 2008, 3:41 pm

    How do i change the scheduler in general?

  • newbie October 17, 2008, 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.?.



  • marco October 17, 2008, 3:57 pm

    Thank you newbie. :)

  • Ratnadeep Joshi November 6, 2009, 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

  • Danny December 29, 2009, 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.

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

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

  • Kedar March 27, 2014, 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.

    • Ron July 28, 2014, 1:55 pm

      @Kedar: you would need to specify how exactly the external disk is attached

  • daft117 July 28, 2014, 8:37 pm

    we can automate this step for every reboot by:

    cat /etc/rc.local | grep -iv “^exit” > /tmp/temp
    echo -e “echo deadline > /sys/block/vda/queue/scheduler\nexit 0” >> /tmp/temp
    cat /tmp/temp > /etc/rc.local; rm /tmp/temp

    as u can see i used deadline for vda in this example.
    it simply ignore “exit” line and add deadline command to reboot script.

    • Cat Grepper October 3, 2015, 11:06 pm

      Advice from a cat grepper should generally be avoided.

  • Todd May 24, 2016, 12:23 pm

    I did: “cat /sys/block/sda/queue/scheduler”
    The output is: “noop deadline [cfq]”
    What does it mean?
    Is my current elevator ‘noop’, ‘deadline’ or ‘cfq’?

    • Terrance June 8, 2016, 3:45 pm

      “noop deadline [cfq]”

      Means that “cfq” is the current elevator.

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , , , ,