Skip to content

Instantly share code, notes, and snippets.

@tsaavik
Last active October 12, 2021 21:56
Show Gist options
  • Save tsaavik/6979047 to your computer and use it in GitHub Desktop.
Save tsaavik/6979047 to your computer and use it in GitHub Desktop.
Inspired by the tuner scripts we used at mp3.com, this sets some performance options for hard disks, and has some specific optimizations for SSD/NVMEs
#!/bin/bash
# Tweak hard drive performance stuff
for drive in sda sdb sdc sdd; do
if [[ -e /dev/${drive} ]] ;then
#increase readahead buffer on sata devices
/sbin/blockdev --setra 2048 /dev/${drive}
echo 1024 > /sys/block/${drive}/queue/read_ahead_kb
if smartctl -a /dev/${drive} |grep SSD;then
#SSDs do not have latency issues like traditional hdd so we tweak
echo "/dev/${drive} is a SSD, tweaking proc entries"
echo deadline > /sys/block/${drive}/queue/scheduler
echo 32 > /sys/block/${drive}/queue/read_ahead_kb
echo 1 >/sys/block/${drive}/queue/iosched/fifo_batch
echo 0 > /proc/sys/vm/swappiness
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment