I am trying to write a service file that unbinds a PCI device like this, after I run systemctl stop servicefile-name:

    ExecStop=/bin/echo 1 > "/sys/bus/pci/devices/0000\:03\:00.0/remove"

However the unbinding never occurs and the device is still active and running. Executing the echo command from the bash command line has no problems and removes the device just fine: echo 1 > /sys/bus/pci/devices/0000:03:00.0/remove

Running systemctl status servicefile-name shows that the echo command ran without any errors: (code=exited, status=0/SUCCESS). I am clearly not using the correct echo command syntax within the service file. I also tried to remove the escape characters but it still did not work

ExecStop=/bin/echo 1 > "/sys/bus/pci/devices/0000:03:00.0/remove"

Does anyone know how to remove/unbind devices at runtime from a systemd service file, give the special characters ":"?

2 Answers 2


ExecStop=... does not run bash. Therefore operators like > or & are not interpreted in the same way that bash would interpret them. systemd will simply run /bin/echo and pass 1, >, and "sys-bus-pci-devices-0000:03:00.0-remove" as arguments.

If you want > to act as bash redirection, then you need to pass this statement to the bash interpreter using bash -c.

Try this:

ExecStop=/bin/bash -c "/bin/echo 1 > /sys/bus/pci/devices/0000\:03\:00.0/remove"

I'm not as familiar with the escaping suggested by GAD3R, but you might also try that escaped string as well.


Use systemd-escape.

$ systemd-escape --path "/sys/bus/pci/devices/0000:03:00.0/remove"

Then edit your unit file:

ExecStop=/bin/echo 1 > "sys-bus-pci-devices-0000:03:00.0-remove"

see man systemd-escape

  • That is not helping, but the reason may be due to the fact that the device's bus ID (0000:03:00.0) is actually a symlink which points to another file. Feb 2, 2022 at 1:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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