4

I would like to change permanently the I/O scheduler for a specific disk on Fedora 20. According to what I have found, this can be achieved by executing the following shell line as root:

echo {SCHEDULER-NAME} > /sys/block/{DEVICE-NAME}/queue/scheduler

However, the change is lost after a reboot. It seems that a mean to achieve what I want is to create a systemd service but I am completely lost since it has to be executed after disks are mounted. Could someone help me to write such a systemd service ? Any other viable solution is also welcome.

1
  • The old-school method was to append the command to /etc/rc.local – HBruijn Jul 16 '14 at 12:01
8

The tuned and tuned-utils pacakages are available for Fedora (they are also in Red Hat). This is a system service that can apply predefined or user-defined system profiles and tuneables on-the-fly, including mount options, disk schedulers, sysctl parameters, etc. Many Liinux admins overlook these settings.

See the Fedora 20 Manual:
http://docs.fedoraproject.org/en-US/Fedora/20/html/Power_Management_Guide/sect-tuned-installation-and-usage.html

Something like:

tuned-adm profile virtual-guest

or

tuned-adm profile enterprise-storage

Here's the schedule of settings for RHEL. Fedora may be slightly different.

enter image description here

I know you're looking for settings on a specific disk, but I tend to apply the I/O scheduling parameters to all of the disks. Either way, see if the predefined profiles work for you (no need to duplicate effort). If not, the profiles are easy to customize.

3
  • The settings look about the same on Fedora, except that Fedora also has a couple of extra profiles for desktop usage. – Michael Hampton Jul 16 '14 at 16:02
  • Thank you for your answer but my goal was to use the noop I/O scheduler on a specific disk. Predefined profiles do not help. Besides, configuring the I/O scheduler for a specific disk seems a bit complex. – Laurent Jul 23 '14 at 16:04
  • 2
    Creating /etc/tuned/myprofile/tuned.conf with few lines: [main], include=someprofile, [disk], devices=sda, elevator=noop, then switching to this profile with tuned-adm profile myprofile is pretty easy and is in place with all other system's fine tuning. – Zart Mar 14 '15 at 20:36
6

You simply have to create a file in /etc/systemd/system/io-scheduler.service with the following content:

[Unit]
Description=I/O Scheduler Setter
After=local-fs.target

[Service]
Type=oneshot
ExecStart=/bin/bash -c 'echo noop > /sys/block/sda/queue/scheduler'
TimeoutSec=0
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Then, enable the service for auto start at boot and start it for the current session with:

chmod 755 /etc/systemd/system/io-scheduler.service
systemctl enable io-scheduler.service
systemctl start io-scheduler.service
1
0

You can change the default scheduler for all disks by adding the following to your kernel command line, which can be found in /boot/grub/menu.lst:

elevator={SCHEDULER-NAME}

0

@ewwhite, you've provided the answer to a question the op didn't ask.

The answer to "change permanently the I/O scheduler for a specific disk" is not provided at the resource you suggested, and the comment "the way Fedora and Red Hat documented and intended" is off-base for several reasons that I won't get into here.

To change the io scheduler for a specific disk, the op has chosen the correct method:

echo noop > /sys/block/sda/queue/scheduler

How he chooses to run this command is somewhat arbitrary; this could be done with a config management application, a script, or a creating a service unit as he has done.


@boscoe - that's going to be a problem on grub2 systems. The question is aimed at F20. Additionally, it will apply the elevator to all disks, which is not what the op was after.

1
  • It's kinda like the X/Y Problem. Why would anyone change the I/O scheduler on a single disk? What problem is that solving? I provided an answer that is intended to help outside of this potentially narrow context. – ewwhite Sep 26 '14 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.