brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: /sys/block/sda/queue/scheduler shows and switches the Linux I/O scheduler of a disk

Linux
~/tips/tip-linux-block-queue-scheduler

cat /sys/block/sda/queue/scheduler

See which I/O scheduler a disk uses and try another one without a reboot.

The kernel decides in which order read and write requests go to a disk. For spinning disks that order matters a lot; for NVMe drives it matters much less. You can see and change the choice per disk.

cat /sys/block/sda/queue/scheduler

The output lists the schedulers that are available, with the active one in brackets, for example [mq-deadline] kyber bfq none. To switch for a test:

echo bfq | sudo tee /sys/block/sda/queue/scheduler

It takes effect at once. As a rough guide: none is the usual default for NVMe, because those drives sort requests themselves. mq-deadline is a safe general choice for SATA disks. bfq aims at fairness and responsiveness, which helps a desktop stay usable while a big copy runs, at the cost of some CPU time. A scheduler that is not in the list is not loaded; modprobe bfq often adds it.

I would only change it after measuring, with the same workload before and after, for example with iostat.

The change does not survive a reboot. For a permanent setting, a udev rule is the usual way, matched on the disk name or on queue/rotational so spinning disks and SSDs each get their own. Virtual disks in a VM or container often show none only, since the host does the real scheduling.

Further reading: Switching scheduler

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link