[SOLVED] Write udev rule to change harddisk timeout
Linux - Virtualization and CloudThis forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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.
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:
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.
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
Anyway, udevtest doesn't work any more since version 0.122 and has been replaced by udevadm test <device>, so
udevadm test /block/sda
srvtest:/etc/udev/rules.d# udevadm test /block/sda
This program is for debugging only, it does not run any program,
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.
add_matching_files: unable to open '/lib/udev/rules.d': No such file or directory
parse_file: reading '/etc/udev/rules.d/50-udev.rules' as rules file
parse_file: reading '/etc/udev/rules.d/60-persistent-input.rules' as rules file
parse_file: reading '/etc/udev/rules.d/60-persistent-storage-tape.rules' as rules file
parse_file: reading '/etc/udev/rules.d/60-persistent-storage.rules' as rules file
parse_file: reading '/etc/udev/rules.d/60-persistent-v4l.rules' as rules file
parse_file: reading '/dev/.udev/rules.d/61-dev-root-link.rules' as rules file
parse_file: reading '/etc/udev/rules.d/70-persistent-cd.rules' as rules file
parse_file: reading '/etc/udev/rules.d/75-cd-aliases-generator.rules' as rules file
parse_file: reading '/etc/udev/rules.d/75-persistent-net-generator.rules' as rules file
parse_file: reading '/etc/udev/rules.d/80-drivers.rules' as rules file
parse_file: reading '/etc/udev/rules.d/81-vmware-timeout.rules' as rules file
parse_file: reading '/etc/udev/rules.d/91-permissions.rules' as rules file
parse_file: reading '/etc/udev/rules.d/95-late.rules' as rules file
import_uevent_var: import into environment: 'MAJOR=8'
import_uevent_var: import into environment: 'MINOR=0'
import_uevent_var: import into environment: 'DEVTYPE=disk'
import_uevent_var: import into environment: 'PHYSDEVPATH=/devices/pci0000:00/0000:00:10.0/host0/target0:0:0/0:0:0:0'
import_uevent_var: import into environment: 'PHYSDEVBUS=scsi'
import_uevent_var: import into environment: 'PHYSDEVDRIVER=sd'
udevtest: looking at device '/block/sda' from subsystem 'block'
udev_rules_get_name: add symlink 'block/8:0'
match_rule: '/sys/block/sda/whole_disk' does not exist
udev_node_mknod: mknod(/dev/.tmp-8-0, 060600, (8,0))
udev_node_mknod: chmod(/dev/.tmp-8-0, 060600)
udev_node_mknod: chown(/dev/.tmp-8-0, 0, 0)
run_program: 'scsi_id --export --whitelisted --device=/dev/.tmp-8-0'
run_program: '/lib/udev/scsi_id' returned with status 1
run_program: 'edd_id --export /dev/.tmp-8-0'
run_program: '/lib/udev/edd_id' (stderr) 'no kernel EDD support'
run_program: '/lib/udev/edd_id' returned with status 2
run_program: 'path_id /block/sda'
run_program: '/lib/udev/path_id' (stdout) 'ID_PATH=pci-0000:00:10.0-scsi-0:0:0:0'
run_program: '/lib/udev/path_id' returned with status 0
udev_rules_get_name: add symlink 'disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0'
run_program: 'vol_id --export /dev/.tmp-8-0'
run_program: '/lib/udev/vol_id' (stderr) '/dev/.tmp-8-0: unknown volume type'
run_program: '/lib/udev/vol_id' returned with status 4
udev_rules_get_name: no node name set, will use kernel name 'sda'
udev_device_event: device '/block/sda' already in database, cleanup
udev_node_add: creating device node '/dev/sda', major=8, minor=0, mode=0660, uid=0, gid=6
udev_node_update_symlinks: update symlink 'block/8:0' of '/block/sda'
udev_db_get_devices_by_name: found index directory '/dev/.udev/names/block\x2f8:0'
update_link: found 1 devices with name 'block/8:0'
update_link: found '/block/sda' for 'block/8:0'
update_link: compare (our own) priority of '/block/sda' 0 >= 0
update_link: 'block/8:0' with target 'sda' has the highest priority 0, create it
udev_node_update_symlinks: update symlink 'disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0' of '/block/sda'
udev_db_get_devices_by_name: found index directory '/dev/.udev/names/disk\x2fby-path\x2fpci-0000:00:10.0-scsi-0:0:0:0'
update_link: found 1 devices with name 'disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0'
update_link: found '/block/sda' for 'disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0'
update_link: compare (our own) priority of '/block/sda' 0 >= 0
update_link: 'disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0' with target 'sda' has the highest priority 0, create it
udevtest: run: '/bin/sh -c 'echo 180 > /sys/block/sda/device/timeout''
udevtest: run: 'socket:@/org/kernel/udev/monitor'
which looked pretty perfect! After a reboot of my testserver the correct value was presented. Thanks again for your help. Moltes graciès!