Debian – the recommended way of setting a default IO scheduler on Linux

configurationdebianioscheduling

I would like deadline to be the default IO scheduler for my system, and I don't want to lose that config when I reboot. What is the proper way of doing that? (I'm using Debian)

Some hints:

  • have a startup script doing echo deadline >| /sys/block/sda/queue/scheduler,
  • use the kernel parameter elevator=deadline on GRUB startup config,
  • use a udev rule like SUBSYSTEM=="block", ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/scheduler}="deadline",
  • etc.

What is the "preferred" solution?

EDIT: can I have a configuration which set the iosched to deadline only for drives present at bootup, but not for subsequent hot-plugged drives (like USB keys)?

Best Answer

Depends on the situation really. All things equal, I would prefer the GRUB approach, purely because it is simple and you get your chosen scheduler right at the start of the boot.

The main issue with it is that it is a system wide setting and if you have more than one disk and want different schedulers on each, then it is no use. The udev approach is better in this case, it offers the most fine grained control. You could even set different schedulers for external disks and they would be activated when you plug them in.

The one I would least prefer is the startup script. The options here are either to put it in the /etc/rc.local script, in which case the scheduler won't change until (very) late in the boot process, or to put it in with the other sysvinit scripts. The latter is the most complicated of all as it requires writing LSB tags etc to do it properly. Also, it is more difficult (for me at least) to reliably get the correct disk via /sys. Note the example you give won't work if the disk you are trying to set the scheduler for is no longer sda for whatever reason. With udev you can match the device(s) according to a range of properties.

Related Question