Table of Contents
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.
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]
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.
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.
I discovered your site from Google and I have to state it was a great discover.
Many thanks!