[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

udev rule writing help needed



I have a new Seagate FreeAgent usb hard drive.  After install, it
spins down and when one tries to write to it, it gets marked read only.
This can be prevented by running the following command line:

echo 1 > /sys/class/scsi_disk/14\:0\:0\:0/allow_restart

where this bit                ^^^^^^^^^^^
varies with each connection.

I'd like to get udev to set this for me, so I tried the following rule:

SYSFS{model}=="FreeAgentDesktop",RUN+="/bin/echo 1 > /sys/class/scsi_disk/%k/allow_restart"

It doesn't work.  Allow_restart is always 0 after a connection.

I've also tried:
SYSFS{model}=="FreeAgentDesktop",RUN+="/bin/echo 1 > /sys/class/scsi_disk/%b/allow_restart"
SYSFS{model}=="FreeAgentDesktop",RUN+="/bin/echo 1 > '/sys/class/scsi_disk/%k/allow_restart'"
SYSFS{model}=="FreeAgentDesktop",RUN+="/bin/echo 1 > '/sys/class/scsi_disk/%b/allow_restart'"

because I'm confused about 1) which string substitution holds the
identifier I need, and 2) the need for quoting or escaping the ':' in
the line.

udevtest shows this:
parse_file: reading '/etc/udev/rules.d/10-local.rules' as rules file
and this
main: run: 'socket:/org/freedesktop/hal/udev_event'
so my rule seems to be picked up.

udevinfo -a -p /sys/block/sdd
shows:
  looking at parent device '/devices/pci0000:00/0000:00:06.0/0000:02:0b.2/usb5/5-3/5-3:1.0/host14/target14:0:0/14:0:0:0':
    KERNELS=="14:0:0:0"
   ATTRS{model}=="FreeAgentDesktop"
...

So my questions are: 1) what string substitution do I use to get the needed bit into my command?
2) do I need quoting in the rule?
3) can this work anyway?

Thanks for any help.

Don

--
Don.Hayward at pomobuli.net -- debian/rules -- Registered Linux user #374806
- History is the best antidote to illusions of omnipotence and omniscience.
- It should forever remind usof the limitations of our passing perspectives.
- It should strengthen us to resist the pressure to convert momentary
-   interests into moral absolutes. -- Arthur Schlesinger Jr.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: