I have an SSD in my laptop and I've been told that switching to the "noop" scheduler is preferred.
How do I change to the noop scheduler, and where do I make the change so that it is persistent across reboots?
Suppose your hard disk is /dev/sda
. Then you could check to see what scheduler is currently in use for it:
cat /sys/block/sda/queue/scheduler
(The scheduler currently in use will be surrounded by [
]
brackets.)
And you could make it use the noop scheduler:
echo noop > /sys/block/sda/queue/scheduler
See this article for slightly more information.
To make the change persist, you can put the command in /etc/rc.local
.
sudo echo noop > /sys/block/sda/queue/scheduler
? That doesn't work, as the shell, which runs as your user, sets up the redirection before running the command whose output is redirected. You can use echo noop | sudo tee /sys/block/sda/queue/scheduler
instead. See Cannot echo “hello” > x.txt even with sudo? and How to solve “permission denied” when using sudo with redirection in Bash? for more information and other approaches. (If that's not what you mean, please let me know.)
Commented
Jun 17, 2019 at 17:53
Edit /etc/default/grub, such as gksudo gedit /etc/default/grub
, here you need to add elevator=noop.
Change GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
to GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=noop"
.
Then run sudo update-grub2
and restart.
elevator=
kernel argument was removed in kernel v5.4, which is used since Ubuntu 20.04 LTS focal. github.com/torvalds/linux/commit/…
Commented
Apr 24, 2020 at 8:58
This Debian reference shows how to dynamically detect SSDs and change the scheduler accordingly:
In systems with different drive types you can adjust settings with a udev rule (create /etc/udev/rules.d/60-ssd-scheduler.rules):
# Set deadline scheduler for non-rotating disks
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0",ATTR{queue/scheduler}="deadline"
To make sure that your kernel can detect rotational status:
$ for f in /sys/block/sd?/queue/rotational; do printf "$f is "; cat $f; done
/sys/block/sda/queue/rotational is 1
/sys/block/sdb/queue/rotational is 1
/sys/block/sdc/queue/rotational is 0 <=== Only this is SSD!
All of the above is quoted directly from the Debian reference, which has many other elements of interest to first-time SSD users.
vi /etc/rc.local
Add line
for f in /sys/block/sd?/queue/scheduler; do echo "noop" > $f; cat $f; done
Then run the command
chmod +x /etc/rc.local