Making stripe_cache_size permanent

I did

echo 8192 > /sys/block/md0/md/stripe_cache_size

to improve my RAID performance, and it did helped alot.

But I still can't figure out how to make it permanent.

I was trying to set it in /etc/rc.local - other commands are executed, but it was overwritten to 256 elsewhere... Any hints?


Add a udev rule, e.g. to /etc/udev/rules.d/60-md-stripe-cache.rules:

SUBSYSTEM=="block", KERNEL=="md*", ACTION=="change", TEST=="md/stripe_cache_size", ATTR{md/stripe_cache_size}="8192"

I haven't actually tried this so it might not be 100% right (may be some typos), but it should be close. Check man udev to understand more.

You may also want to run the following commands afterwards to immediately apply the new rule:

udevadm trigger
udevadm control --reload-rules

Just to expand on the last post; the script underneath works for me. Just swap your details between the "<...>". Enjoy!


#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

#################NOTE######################
##  You are limited by CPU and memory too #
##  <Your Name> <Date of Modification>    #
##  stripe cache size and read-ahead      #
###########################################
echo 16384 > /sys/block/<Your RAID5 or 6 Volume>/md/stripe_cache_size
blockdev --setra 16384 /dev/<Your RAID5 or 6 Volume>

exit 0