How do I change the I/O scheduler for a particular hard disk without rebooting my Linux server system?
CFQ [cfq] (Completely Fair Queuing) is an I/O scheduler for the Linux kernel and default under many Linux distributions.
Noop scheduler (noop) is the simplest I/O scheduler for the Linux kernel based upon FIFO queue concept.
Anticipatory scheduler (anticipatory) is an algorithm for scheduling hard disk input/output as well as old scheduler which is replaced by CFQ
Deadline scheduler (deadline) – it attempt to guarantee a start service time for a request.
Task: View Current Disk scheduler
Assuming that your disk name /dev/sda, type:
# cat /sys/block/{DEVICE-NAME}/queue/scheduler
# cat /sys/block/sda/queue/scheduler
Sample output:
noop anticipatory deadline [cfq]
Task: Set I/O Scheduler For A Hard Disk
To set a specific scheduler, simply type the command as follows:
# echo {SCHEDULER-NAME} > /sys/block/{DEVICE-NAME}/queue/scheduler
For example, set noop scheduler, enter:
# echo noop > /sys/block/hda/queue/scheduler
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 12 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
How do i change the scheduler in general?
Edit /boot/grub/grub.conf and enter in kernel line elevator=noop or any other scheduler available.
Kernel compilation should also be a way I think.?.
http://www.redhat.com/magazine/008jun05/features/schedulers/
Greetz
Thank you newbie. :)
You can echo to /sys/block//queue/scheduler/
e.g. If you want the scheduler to be ‘noop’ for ‘sda’, you should run:
# echo noop > /sys/block/sda/queue/scheduler
“But I’m on Ubuntu, and I want to do it without enabling the root account or running sudo su –:
echo anticipatory | sudo tee /sys/block/sdb/queue/scheduler
Also note that, if you’re using lvm, you’ll have the physical devices (like sda) as well as the virtual devices (like dm-1). Same goes for software raid – you’ll have md0, etc. It’s unclear to me which setting wins if you are running lvm on top of software raid (which isn’t incredibly uncommon), and have different schedulers set for the physical disks, raid devices, and lvm devices…
PS: it looks like you can find out which LVM volume maps to “dm-6”, for example, by dong an ls -l on /dev/block/252:*. On one of my machines, I get
lrwxrwxrwx 1 root root 18 2009-12-12 21:53 /dev/block/252:6 -> ../mapper/pyro-var
Which indicates that dm-6 is currently the “var” volume in the “pyro” volume group.
How to change the linux scheduler for user fairness ???
I cant find device name of my attached device in /sys/block/ since its attached external drive. Therefore I cant see current io-scheduler for this disk.
Please help.
@Kedar: you would need to specify how exactly the external disk is attached
we can automate this step for every reboot by:
cat /etc/rc.local | grep -iv “^exit” > /tmp/temp
echo -e “echo deadline > /sys/block/vda/queue/scheduler\nexit 0” >> /tmp/temp
cat /tmp/temp > /etc/rc.local; rm /tmp/temp
as u can see i used deadline for vda in this example.
it simply ignore “exit” line and add deadline command to reboot script.
Advice from a cat grepper should generally be avoided.
I did: “cat /sys/block/sda/queue/scheduler”
The output is: “noop deadline [cfq]”
What does it mean?
Is my current elevator ‘noop’, ‘deadline’ or ‘cfq’?
Thanks
“noop deadline [cfq]”
Means that “cfq” is the current elevator.