Write udev rule to change harddisk timeout
Hi all,
I want (have to) change the timeout on the harddisks of our VMWare virtual machines in Debian 5. Right now I run a small script to set the timeout manually at boot using rc.local. I would like to have it applied using a udev rule but haven't got a clue where to start. I've been reading and searching but cannot get it to work. Our vendor provided a script for Suse and RedHat. I've tried changing the RedHat script for Debian but it doesn't work at all. Here's the udevinfo output of the disk in question. Code:
looking at device '/block/sda': All help is greatly appreciated. Kind regards, Eric |
Hi,
After some more reading and searching I put this construct in /etc/udev/rules.d/81-vmware-timeout.rules Code:
ACTION=="add", KERNEL=="sda", SUBSYSTEM=="block", RUN+="/bin/sh -c 'echo 180 > /sys/$devpath/timeout'" Kind regards, Eric |
Three parts to this; is the match working, is the RUN command being run and if so is it doing what was intended?
You could write a shellscript and call that instead of "/bin/sh -c 'echo 180 > /sys/$devpath/timeout'". The shellscript could write its command line and the echo command to log. |
Hi catkin,
Thanks for your reply. The udev rule isn't doing anything at all. The timeout value doesn't get changed. I currently do it using a script but would prefer putting it in a udev rule. Any ideas? Kind regard, Eric |
EricTra,
You are on the right path with the following Code:
ACTION=="add", KERNEL=="sda", SUBSYSTEM=="block", RUN+="/bin/sh -c 'echo 180 > /sys/$devpath/timeout'" Code:
ACTION=="add", KERNEL=="sda", SUBSYSTEM=="block", PROGRAM="/bin/sh -c 'echo 180 > /sys/$devpath/timeout'" |
Hello and Welcome to LinuxQuestions,
Thank you very much for your reply, I'll try it out and let you know. Have fun using Linux. Kind regards, Eric |
Quote:
No joy :( Tried different rule files without any result, not restarting udev nor rebooting. It just doesn't get applied. Could this have to do with the machines being virtual? [EDIT] Just tried it on a physical server with Debian and doesn't work either. [/EDIT] Kind regards, Eric |
Hi Eric,
pay attention to the fact that $devpath is substituted by "/block/sda", so that the path of the timeout file should be "/sys$devpath/device/timeout" (your rule lacks the device directory). As previously suggested you can test the rule with udevtest (when the disk is mounted) and if the rule's action is: Code:
... RUN+="/bin/sh -c 'echo 180 > /sys$devpath/device/timeout'" Code:
$ udevtest /block/sda You may also want to refine your rule to match against that particular device, since "KERNEL=="sda", SUBSYSTEM=="block", is a bit too generic. For example you can try to add the "vendor" attribute which identifies a VMware disk and/or the "size" attribute, if fixed. Cheers! Alex |
Hola Alex,
It's working!!! Thank you so much. The basic stuff is what gets forgotten first I think. I didn't think about to what the devpath variable was pointing, feeling pretty green right now :o Anyway, udevtest doesn't work any more since version 0.122 and has been replaced by udevadm test <device>, so Code:
udevadm test /block/sda Code:
srvtest:/etc/udev/rules.d# udevadm test /block/sda Kind regards, Eric |
Hola! You're welcome! Glad to see it works now. And thank you for the notice about udevadm... I always forget it (old habits are hard to die). :)
|
All times are GMT -5. The time now is 11:09 PM. |