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 likeSUBSYSTEM=="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 othersysvinit
scripts. The latter is the most complicated of all as it requires writingLSB
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 longersda
for whatever reason. Withudev
you can match the device(s) according to a range of properties.