LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This 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.

Notices


Reply
  Search this Thread
Old 05-26-2010, 04:12 AM   #1
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
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':
    KERNEL=="sda"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{range}=="16"
    ATTR{removable}=="0"
    ATTR{size}=="16777216"
    ATTR{capability}=="12"
    ATTR{stat}=="    1206      829    37844     1664     1192     2335    28216      404        0     1724     2068"

  looking at parent device '/devices/pci0000:00/0000:00:10.0/host0/target0:0:0/0:0:0:0':
    KERNELS=="0:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{device_blocked}=="0"
    ATTRS{type}=="0"
    ATTRS{scsi_level}=="3"
    ATTRS{vendor}=="VMware  "
    ATTRS{model}=="Virtual disk    "
    ATTRS{rev}=="1.0 "
    ATTRS{state}=="running"
    ATTRS{timeout}=="30"
    ATTRS{iocounterbits}=="32"
    ATTRS{iorequest_cnt}=="0x979"
    ATTRS{iodone_cnt}=="0x979"
    ATTRS{ioerr_cnt}=="0xa"
    ATTRS{modalias}=="scsi:t-0x00"
    ATTRS{evt_media_change}=="0"
    ATTRS{queue_depth}=="32"
    ATTRS{queue_type}=="simple"

  looking at parent device '/devices/pci0000:00/0000:00:10.0/host0/target0:0:0':
    KERNELS=="target0:0:0"
    SUBSYSTEMS==""
    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:10.0/host0':
    KERNELS=="host0"
    SUBSYSTEMS==""
    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:10.0':
    KERNELS=="0000:00:10.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="mptspi"
    ATTRS{vendor}=="0x1000"
    ATTRS{device}=="0x0030"
    ATTRS{subsystem_vendor}=="0x0000"
    ATTRS{subsystem_device}=="0x0000"
    ATTRS{class}=="0x010000"
    ATTRS{irq}=="17"
    ATTRS{local_cpus}=="ff"
    ATTRS{local_cpulist}=="0-7"
ATTRS{modalias}=="pci:v00001000d00000030sv00000000sd00000000bc01sc00i00"
    ATTRS{enable}=="1"
    ATTRS{broken_parity_status}=="0"
    ATTRS{msi_bus}==""

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
I also don't know if I should add it to 50-udev.rules, 60-persistent-storage.rules or create a new rule file.

All help is greatly appreciated.

Kind regards,

Eric
 
Old 05-26-2010, 06:07 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805

Original Poster
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
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'"
but it's not doing a thing. Can someone point me to the error or reason why it's not working?

Kind regards,

Eric
 
Old 05-26-2010, 06:32 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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.
 
Old 05-26-2010, 07:28 AM   #4
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805

Original Poster
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
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
 
Old 06-10-2010, 01:16 PM   #5
mxwlpxwl
LQ Newbie
 
Registered: Jun 2010
Posts: 1

Rep: Reputation: 1
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'"
testing the rule first with "/usr/bin/udevtest /block/sda" will allow you to see where you messed up. I'm no expert on debian, but you may want to try

Code:
ACTION=="add", KERNEL=="sda", SUBSYSTEM=="block", PROGRAM="/bin/sh -c 'echo 180 > /sys/$devpath/timeout'"
Bueno Suerte
 
1 members found this post helpful.
Old 06-11-2010, 12:17 AM   #6
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805

Original Poster
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
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
 
Old 06-11-2010, 01:12 AM   #7
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805

Original Poster
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Quote:
Originally Posted by mxwlpxwl View Post
Code:
ACTION=="add", KERNEL=="sda", SUBSYSTEM=="block", PROGRAM="/bin/sh -c 'echo 180 > /sys/$devpath/timeout'"
Bueno Suerte
Hi,

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

Last edited by EricTRA; 06-11-2010 at 01:25 AM.
 
Old 06-11-2010, 04:38 AM   #8
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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'"
you should see this at some point:
Code:
$ udevtest /block/sda
<omitted>
main: run: '/bin/sh -c 'echo 180 > /sys/block/sda/device/timeout''
<omitted>[/CODE]
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
 
1 members found this post helpful.
Old 06-11-2010, 05:29 AM   #9
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805

Original Poster
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
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

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
returned this:
Code:
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'
srvtest:/etc/udev/rules.d#
which looked pretty perfect! After a reboot of my testserver the correct value was presented. Thanks again for your help. Moltes graciès!

Kind regards,

Eric
 
Old 06-11-2010, 06:55 AM   #10
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
First UDEV Rule, Not quite there ... orbit Slackware 7 02-22-2009 10:08 PM
udev rule: need help DPenguin Linux - Hardware 0 08-04-2008 07:29 PM
Udev Rule Help Please Toods Slackware 1 11-23-2007 08:55 AM
need help with udev rule hussam Linux - Software 2 12-05-2006 03:30 AM
need help: write udev rule for LIRC, digital setopbox NoMoreReinstallMS Linux - Hardware 0 11-24-2006 03:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 12:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration