How to change IO scheduler permanently in Linux


Written by - Deepak Prasad

In my last article I gave an overview on I/O related optimization and performance improvement, now in this article I will share the steps to change IO scheduler (permanently or temporarily) in Linux.

 

How to change IO scheduler permanently in Linux

 

One of the more controversial tunable Linux performance features, in that there are no universally accepted guidelines available, is that of the I/O scheduler choice.

  • The name elevator is used due to how they sort incoming requests.
  • Consider a real elevator, currently at the first floor.
  • Perhaps the first person in requests the ninth floor, then the next person the third.
  • The elevator will not visit the floors in the order requested; it will visit the third floor first, then continue to the ninth.
  • The scheduler elevator does read and write sorting to optimize in a similar fashion.

 

How to change IO scheduler for runtime (temporary)?

You can check the currently active scheduler using the below file and command

# cat /sys/block/sda/queue/scheduler
noop [deadline] cfq

To change the active scheduler for the current session

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

Now again validate the active scheduler

# cat /sys/block/sda/queue/scheduler
noop deadline [cfq]
NOTE:
This change is not persistent and will switch back to deadline after reboot of the node

 

How to change IO scheduler permanently using GRUB2?

You can set the default elevator scheduler at kernel boot time. Modify your GRUB configuration and add your choice of elevator in the format shown below under GRUB_CMDLINE_LINUX

# cat /etc/sysconfig/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet elevator=cfq"
GRUB_DISABLE_RECOVERY="true"

Next rebuild your initramfs

# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-862.14.4.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-862.14.4.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-43f0510283784c858d39e38e358b4669
Found initrd image: /boot/initramfs-0-rescue-43f0510283784c858d39e38e358b4669.img
done

Reboot the node to activate the changes

Once the node is back UP, check the active scheduler

# cat /sys/block/sda/queue/scheduler
noop deadline [cfq]

So as expected the active scheduler is "cfq" as we set with kernel

 

How to change IO scheduler permanently using GRUB2?

You can also use tuned profile to permanently change your active IO scheduler. Create your own tuned profile and add below content in the tuned.conf file

[disk]
elevator=deadline

Here we are setting deadline as my default IO scheduler.

Next activate the tuned profile. Here golinuxcloud is my custom tuned profile

# tuned-adm profile golinuxcloud

Now validate the active scheduler

# cat /sys/block/sda/queue/scheduler
noop [deadline] cfq

So as expected our active scheduler as changed again.

NOTE:
Now the above steps can change your active IO sceduler and make it persistent to reboot but to modify one of the tunables which is part of these elevator, you will need the steps from below article
How to make IO disk scheduler change reboot persistent in Linux

 

Lastly I hope the steps from the article to configure NIC teaming on Linux was helpful. So, let me know your suggestions and feedback using the comment section.

 

Views: 4

Deepak Prasad

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects. You can reach out to him on his LinkedIn profile or join on Facebook page.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

1 thought on “How to change IO scheduler permanently in Linux”

Leave a Comment