The IO scheduler is the part of the kernel which decides which read or write request to perform next. The Linux kernel has a choice of four, but most distributions use the default “cfq” (completely fair queuing) scheduler, it has been the default in Linux since version 2.6.18, released in September 2006 (Xandros uses 2.6.21 and most current distributions use 2.6.22 or 2.6.24). It's generally a good all-round scheduler and should offer good performance while sharing drive access “completely fairly” between all the different processes which are trying to access a drive at the same time. On hard drives it seems to live up to its name. On flash it doesn't seem to, hence this page.
If you're using the default Xandros you don't need to worry, the Xandros kernel doesn't have cfq built in, let alone used by default. If you use another Linux distribution you should care - you might improve your drive performance and experience greatly improved responsiveness under heavy disk usage just by making a couple of simple tweaks.
Changing the IO scheduler is easy. You don't need to get a new kernel or even reboot. This means you can change it at will and see how much of a difference it makes.
You can get a list of the schedulers available to you, and the currently selected scheduler by viewing the contents of /sys/block/sdX/queue/scheduler (replace sdX as appropriate, eg sda, not sda1 - the scheduler works on whole devices, not partitions). You need to be root (or use sudo). For example:
debeee:~# cat /sys/block/sdb/queue/scheduler noop anticipatory deadline [cfq]
That shows that sdb is currently using the “cfq” IO scheduler and the noop, anticipatory and deadline schedulers are also available.
To select another scheduler, write its name to the same file, eg:
echo deadline > /sys/block/sdb/queue/scheduler
The change happens effectively instantly, even if the disk is being accessed.
Making the change as described above is quick and simple, but you need to do it for each drive individually and every time it's mounted (every boot and every time you reinsert a removable drive). It's much easier if you make your preferred scheduler the default for the whole system. That way you also get the benefits during boot. You can do this by adding a parameter to the kernel. Most distributions use the Grub bootloader, so typically you'd do this by editing /boot/grub/menu.lst, but your distribution may be different. To make the deadline scheduler the default, you would add this to the end of the “kernel” line:
elevator=deadline
Ideally you should try them all under a variety of loads to see which works the best for you, then let the world know your results thorough this page. My own tests on the internal SSD, a 512MB PNY USB flash drive and a 16 GB Corsair Voyager GT US flash drive indicate that the “deadline” scheduler provides the best combination of benchmark performance and responsiveness under load. If you do comparative benchmarking with an SD/SDHC/MMC card and find a different result, update the wiki.
You can read aout the different schedulers on Wikipedia:
Noop_scheduler anticipatory_scheduling Deadline_scheduler CFQ
All the IO schedulers (apart from noop) have various tuning “knobs” which you can use to alter their performance. They live in /sys/block/sdX/queue/iosched/. You can read about them in the Linux kernel documentation.
A useful tweak for the deadline scheduler on flash devices is:
echo 1 > /sys/block/sdX/queue/iosched/fifo_batch
This stops the scheduler grouping reads and writes in an effort to reduce disk head seeks - doing so is futile on a device with no heads to seek.
Some kernels (like the defaut Xandros kernel on the Eee) may not have all the schedulers built in, or they may have them compiled as modules. If they're compiled as modules, you need to load the module before you can select that scheduler. If you know what the modules are called, update this wiki page! rio b and you sfr