Ask Your Question

How can udevadm be run with root privileges after resuming from suspend?

asked 2017-02-23 12:52:58 -0600

SauravSengupta gravatar image

updated 2017-02-23 13:41:36 -0600

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:

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-03-02 13:13:44 -0600

SauravSengupta gravatar image

It seems that I had been using the wrong path for udevadm. The correct path for it in the service unit file should be /sbin/udevadm (or /usr/sbin/udevadm), otherwise it does not run with enough privileges to work.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-02-23 12:52:58 -0600

Seen: 237 times

Last updated: Feb 23 '17