Performance Tuning for Linux Software Raid

After finishing my Homeserver project I wanted to get the maximum of performance. At the end of my research in the web i have created following script:

# Get Arrays and physical Disks for active Raid5 Volumes

ARRAYS=""
DISKS=""

for field in `cat /proc/mdstat | grep "active raid5"`
do
  if [[ "x${field:0:2}x" == "xmdx" ]]
  then
    ARRAYS="$ARRAYS $field"
  elif [[ "x${field:0:2}x" == "xsdx" ]]
  then
    DISKS="$DISKS ${field:0:3}"
  fi
done

# Changes on physical Devices
for disk in $DISKS
do
  #Set read-ahead to 16MB
  blockdev --setra 16384 /dev/$disk
  #Device Queue Tuning
  echo 1024 > /sys/block/$disk/queue/read_ahead_kb
  echo 256 > /sys/block/$disk/queue/nr_requests
  #Disable NCQ
  echo 1 > /sys/block/$disk/device/queue_depth
done

# Changes on Raid Arrays
for array in $ARRAYS
do
  #Set read-ahead to 64MB
  blockdev --setra 64536 /dev/$array
  #Increase stripe-cache size
  echo 16384 > /sys/block/$array/md/stripe_cache_size
done

This are the optimal and tested settings for my system. The numbers can differ from system to system. You have to test.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.