How can udevadm be run with root privileges after resuming from suspend?
I am using Fedora 25. My hard drive gets set to a very low APM level (power saving). I have set up udev rules to adjust the levels for on-battery and plugged-in states using hdparm
. This works as expected. Now I would like to trigger them after waking from suspend/hibernate. This works by running udevadm
with root privileges from the terminal/command-line, but not from scripts. The command is:
/usr/bin/udevadm trigger --match-subsystem="power_supply"
I tried creating a systemd service as mentioned in this: http://unix.stackexchange.com/questions/99120/trigger-udev-rules-from-systemd
I have tried the solution mentioned in the above, executing the command as /bin/sh -c '/usr/bin/udevadm trigger --match-subsystem="power_supply"'
, without success. I have also tried the following:-
- Prefixing the
ExecStart
command line with a+
. - Adding a
User=root
directive. - Putting the
udevadm trigger
command in a separate script and executing that. - Executing it from a script in
/etc/pm/sleep.d/
and/usr/lib64/pm-utils/sleep.d/
instead of using a systemd service.
None of this works. Either the script isn't being run at all, or the udevadm
command isn't getting root privileges. How can I run the udevadm trigger
command with root privileges from either a systemd service or from a pm-utils script after resuming from suspend?