Specify I/O Scheduler per Device

Since the advent of systemd the use of /etc/rc* startup-scripts has been discouraged and phased out. However, systemd still supports the use of certain local startup scripts for compatibility purposes. This post will briefly outline the use of the /etc/rc.local file to assign a specific I/O scheduler to a specific HDD.

At the moment, I have an SSD drive (primary /dev/sda) and an "old-fashioned" HDD (/dev/sdb) in use on my RHEL7 system.  I'd like to be able to use the deadline I/O scheduler as the default and assign the cfq scheduler to the HDD device.  In RHEL7 the default I/O scheduler can change based on the selected tuned profile, which adds an additional layer of uncertainty if you're unaware of "tuned".  The default tuned profile is throughput-performance, which enables the deadline scheduler by default among other performance-related system settings.  However, if the default profile is changed to , e.g. virtual-host, the scheduler of choice becomes cfq--at least on my system.  While the deadline scheduler might outperform the others when dealing with SSDs, cfq is generally recommended for spinning drives.

Default Scheduler as Kernel Parameter

Therefore, in order to assert to the kernel that we intend to retain deadline as the default scheduler despite the change to cfq for /dev/sdb, the following kernel parameter should be appended to the GRUB_CMDLINE_LINUX line in /etc/default/grub:

elevator=deadline

Startup Script for Other Device's Scheduler

First and foremost, the prepended comments in the /etc/rc.local file (which is actually a soft-link to /etc/rc.d/rc.local) advise that the file needs to be executable in order to be executed during boot.  So, as the root user execute

chmod +x /etc/rc.d/rc.local

Thereafter, we can add a single line to the end of this file changing /dev/sdb's I/O scheduler to cfq.

echo cfq > /sys/block/sdb/queue/scheduler

Popular posts from this blog

Password Policy in RHEL 7

Centos 7 pulseaudio

wpa_supplicant and wifi in RHEL 7