Skip to content

Instantly share code, notes, and snippets.

@Caffe1neAdd1ct
Created October 6, 2017 09:29
Show Gist options
  • Save Caffe1neAdd1ct/5ed392dd4003930500f82df648306725 to your computer and use it in GitHub Desktop.
Save Caffe1neAdd1ct/5ed392dd4003930500f82df648306725 to your computer and use it in GitHub Desktop.
Optimise software raid resync linux
#!/bin/bash
### EDIT THESE LINES ONLY
RAID_NAME="md0"
# devices seperated by spaces i.e. "a b c d..." between "(" and ")"
RAID_DRIVES=(b c)
# this should be changed to match above line
blockdev --setra 16384 /dev/sd[bc]
SPEED_MIN=50000
SPEED_MAX=200000
### DO NOT EDIT THE LINES BELOW
echo $SPEED_MIN > /proc/sys/dev/raid/speed_limit_min
echo $SPEED_MAX > /proc/sys/dev/raid/speed_limit_max
# looping though drives that make up raid -> /dev/sda,/dev/sdb...
for index in "${RAID_DRIVES[@]}"
do
echo 1024 > /sys/block/sd${index}/queue/read_ahead_kb
echo 256 > /sys/block/sd${index}/queue/nr_requests
# Disabling NCQ on all disks...
echo 1 > /sys/block/sd${index}/device/queue_depth
done
# Set read-ahead.
echo "Setting read-ahead to 64 MiB for /dev/${RAID_NAME}"
blockdev --setra 65536 /dev/${RAID_NAME}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment