Udev rule not applied on boot for mounted disk

centos7mountudev

I'm trying to persist a readahead rule on a mounted drive to use with mongodb.

The mount is persisted using /etc/fstab and that works as expected.

I have added a udev rule ACTION=="add", KERNEL=="sdb", ATTR{bdi/read_ahead_kb}="16"in /etc/udev/rules.d/85-mongod.rules and confirmed that it works with udevadm test --action=add /sys/block/sdb.

On reboot the disk is mounted but the readahead is set to the default value, not the value set by the udev rule.

I'm running centOS 7.1 on google cloud and mounting a persistent disk.

Is this a race condition or another timing issue? Are there any workarounds? I'm reluctant to use /etc/rc.local since I'm not sure if the disk will always be mounted when it's executed, but not sure if that is actually an issue.

Thanks for any help!

Best Answer

If you have a Red Hat login: https://access.redhat.com/solutions/4378581

cat /lib/tuned/throughput-performance/tuned.conf | grep -iB1 readahead

You will want to change "readahead=>4096" to "readahead=>0".