You can not choose CFQ scheduler in Kubuntu 19.04 since it has been removed from the 5.0 kernel. In my case I need CFQ because it gives the best performance with my rotating hard drive when running a virtual machine with Windows 10 as guest S.O, the other schedulers make the system unusable. Kubuntu 19.04 in the installation by default only offers 2 elevators mq-deadline and none that in my case offer a performance much worse than CFQ.
sudo cat/sys/block/sda/queue/scheduler
mq-deadline none
Only I have to try with 2 other schedulers that do not appear in the installation by default, these scheduler are BFQ and Kyber.
Next I will describe how to enable the BFQ and Kyber modules
1) First verify that the modules exist in the system with the following commands:
sudo modprobe bfq
sudo modprobe kyber-iosched
if there was no error you can verify that the modules are loaded with the command
sudo cat/sys/block/sda/queue/scheduler
which must return
mq-deadline [bfq] kyber none
2) make these modules load with the system start:
sudo -i
echo kyber-iosched > /etc/modules-load.d/kyber-oisched.conf
echo bfq > /etc/modules-load.d/bfq.conf
3) The next step is to tell the system which scheduler to use, then a file is created if it does not exist:
/etc/udev/rules.d/60-scheduler.rules
with the following lines
# set cfq scheduler
ACTION=="add|change",KERNEL=="sd[a-z]",ATTR{queue/rotational}=="1",ATTR{queue/scheduler}="bfq"
ACTION=="add|change",KERNEL=="sr[0-9]",ATTR{queue/rotational}=="1",ATTR{queue/scheduler}="bfq"
if instead of BFQ you want to try kyber, replace the last word of the line where it says "bfq" with "kyber"
4) make the system recognize the changes
sudo udevadm control --reload; sudo udevadm trigger
and the changes are verified with
sudo cat/sys/block/sda/queue/scheduler
mq-deadline kyber [bfq] none
Finished.
Sources:
https://community.chakralinux.org/t/how-to-enable-the-bfq-i-o-scheduler-on-kernel-4-12/6418
https://unix.stackexchange.com/questions/375600/how-to-enable-and-use-the-bfq-scheduler#376136
Depending on your kernel version CFQ might be gone. It was removed as of Kernel 5.0. This is the related commit group.
On a legacy laptop, with a plain old rotational hard disk, BFQ is of the essence to have a responsive system while some other task is accessing the disk in the background. Previously Ubuntu generic kernel used cfq:
after upgrade, stock Ubuntu kernel has CFQ removed (see above), and I found this default:
unacceptable due to extreme lag in the presence of background disk activity. I presume this is much less of a problem on modern hardware with SDD/NVMe mass storage.
As OP says, switching to bfq solves the lag problem.
Marco Gamberoni
Ubuntu 19.04 uses the 5.0 kernel, so CFQ and Deadline are no longer available.
For most workloads even on HDD, using the mq-deadline scheduler is as efficient as using any of the old schedulers. Only for workloads with only sequential disk reads/writes, without any other interference are the old schedulers faster.