Skip to content

Instantly share code, notes, and snippets.

@frace
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save frace/8906634 to your computer and use it in GitHub Desktop.

Select an option

Save frace/8906634 to your computer and use it in GitHub Desktop.
A "collection" of approaches to set the io scheduler for ssds on systems where both ssds and hdds are used.
# An openrc init script (local.d) which sets the io scheduler in "/sys/block/sd?/queue/scheduler"
# for a custom list of known solid state drives.
enable=false
local_start()
{
local ssd_scheduler
local -a ssd_devices
ssd_scheduler="deadline"
ssd_devices=(
"sda"
"sdb"
)
for ssd in "${ssd_devices[@]}"; do
if [[ -e "/dev/${ssd}" ]]; then
echo "$ssd_scheduler" > "/sys/block/${ssd}/queue/scheduler"
fi
done
return 0
}
if $enable; then
local_start
fi
# An udev rule which sets the io scheduler for ssds based on "/sys/block/sd?/queue/rotational"
# in "/sys/block/sd?/queue/scheduler" automatically.
# https://wiki.debian.org/SSDOptimization#Low-Latency_IO-Scheduler
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment