Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to change the value of /sys/bus/usb/devices/4-3/power/wakeup at every boot (4-3 according to my lsusb, it's the keyboard ID).

The default value is:

# cat /sys/bus/usb/devices/4-3/power/wakeup

The classic "online" editing works as expected:

# echo disabled > /sys/bus/usb/devices/4-3/power/wakeup
# cat /sys/bus/usb/devices/4-3/power/wakeup

I'm using a systemd distro so I'd like to use the systemd-way to edit "temp files"

I have created the following file:

# cat /etc/tmpfiles.d/disable-usb-wakeup.conf 
w /sys/bus/usb/devices/4-3/power/wakeup - - - - disabled

but after every boot I still have the default value in this file (i.e. enabled)

I'm doing something wrong?


I have done another test:

# cat /etc/tmpfiles.d/scheduler.conf 
w /sys/block/sda/queue/scheduler - - - - deadline

and this one works fine! After boot I have:

# cat /sys/block/sda/queue/scheduler 
noop [deadline] cfq 

(the default one was the cfq scheduler)

So, why this one works and the other one not?

  • Because /sys/bus/usb/devices/4-3/power/wakeup is a symlink to /sys/devices/pci0000:00/0000:00:12.1/usb4/4-3/ ?
  • Because /sys/bus/usb/devices/4-3/power/wakeup contains only one word? (i.e. no spaces)
share|improve this question
add comment

1 Answer

[ My original idea that this could be because systemd-tmpfiles uses stream I/O and was not intended to be used with proc or sys is wrong. My 2nd hypothesis, about the significance of a newline, was also wrong... ]

I just looked at /usr/lib/systemd/system/systemd-tmpfiles-setup.service and there's a couple of bits in there that may be of interest:

Description=Recreate Volatile Files and Directories
After=systemd-readahead-collect.service systemd-readahead-replay.service local-fs.target
Before=sysinit.target shutdown.target


ExecStart=/usr/bin/systemd-tmpfiles --create --remove

The 'Wants', 'After', and 'Before' give some information about when this happens; I would think your device is registered by this point, but there could be something subsequent that resets the sysfs value.

The most helpful bit is the ExecStart line, because that's the actual command that accounts for this service. This is actually mentioned in man systemd-tmpfiles:

For example, during boot the following command line is executed to ensure that all temporary and volatile directories are removed and created according to the configuration file:

systemd-tmpfiles --remove --create

So, to test this, set the sysfs value to "enabled" and then try running systemd-tmpfiles --create which will process your 'w' directive in /etc/tmpfiles.d. If that works (it should!), then you know that the systemd-tmpfile method is fine, just you have to do it later in the boot process, perhaps with:


Which means writing your own service file; if for some reason it doesn't work, you can always write a service file for a script to do it with echo.

share|improve this answer
I don't think that systemd can't write on virtual file systems. Using tmpfiles on /proc/acpi/wakeup works fine, for example (wiki.archlinux.org/index.php/Systemd#Temporary_files) –  ital Jan 14 '13 at 8:49
@ital : I was probably wrong about that, but if you are still frustrated try my second hypothesis above. –  goldilocks Jan 14 '13 at 12:46
Using echo -n disabled > /sys/... works, so probably the newline presence doesn't care in this case. But tmpfiles is still not working, I've tried both disabled\n and "disabled\n" –  ital Jan 14 '13 at 16:50
I have edited the first post with another test and some hypothesis. –  ital Jan 14 '13 at 17:58
@ital Sheesh. Okay, pretty sure my 3rd guess is the lucky one, so I edited that in above again, lol. If after that you need the basics for writing and registering a systemd service, ask a new question and maybe reference this one; I can explain it without all this clutter, we will get some input from others, and the question can stand for posterity (I don't see any here yet that address this very well). –  goldilocks Jan 14 '13 at 19:07
show 2 more comments

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.