Simple udev Manipulations

When discovering the /sys file system, one can find quite a number of tunables that look interesting and really have effect on system behavior. Especially when experimenting with different values of read ahead for block devices or e.g. setting the stripe_cache_size for raid5, the performance for my software raid was improved a lot.

To make that settings permanent, one can try and go for /etc/init.d/boot.local. More elegant however is to add some udev rule that does the necessary changes for you. It turns out, that this is quite easy. For example, the read ahead for block devices is found in /sys/block/*/bdi/read_ahead_kb. To check your current read ahead of /dev/sda, you may use:

cat /sys/block/sda/bdi/read_ahead_kb

However you may also want to change that setting. To accomplish that, just echo the desired number into the read ahead:

echo 4100 > /sys/block/sda/bdi/read_ahead_kb

To automatically do the setting when the device appears, just add the following file to /etc/udev/rules.d/83-ra.rules:

cat /etc/udev/rules.d/83-ra.rules
# increase readahead for sd* devices
ACTION=="add", KERNEL=="sd*", ATTR{bdi/read_ahead_kb}="4100"

When adding a udev rule for this, one just needs to know that “==” (two equal signs) is a check, and “=” (one equal sign) is a setting.

Note, that some devices may take the read ahead from the underlying device; noteably when using drbd, setting the read ahead on the underlying device will have the desired effect.

This entry was posted in block devices, Hardware, openSUSE. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s