Search code examples
servicesystemd

systemd service start fails: no service.mount unit


I wrote a program (node js, on Raspberry Pi) that I can start manually, but not as a systemd service:

pi@blueberry ~ $ systemd --version
systemd 215
+PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ -SECCOMP -APPARMOR
pi@blueberry ~ $ sudo systemctl daemon-reload
pi@blueberry ~ $ sudo systemctl start /etc/systemd/system/rfxtrx.service
Failed to start etc-systemd-system-rfxtrx.service.mount: Unit etc-systemd-system-rfxtrx.service.mount failed to load: No such file or directory.
pi@blueberry ~ $ 

The error message complains that there is no rfxtrx.service.mount unit. Correct. Should there be such unit? The most common suggestion is to daemon-reload; this doid not help. Or as per https://github.com/systemd/systemd/issues/5375 this could be a bug in systemd that was fixed but only in a later systemd version than the one in raspbian (raspbian has version 215).

Is there any other solution than trying to update to a version not supported by the raspbian maintainers?


Solution

  • Well the first problem here is that you're running to start the service name rfxtrx.service however systemd is expecting etc-systemd-system-rfxtrx.service.mount.

    If you are trying to have a systemd mount configuration then your file name should follow the following rule:

    Mount units must be named after the mount point directories they control. Example: the mount point /home/lennart must be configured in a unit file home-lennart.mount.

    So if you were wanting to create a mount point at say /dir/to/rfxtrx then the systemd mount file needs to be named dir-to-rfxtrx.mount, and it's recommended that it sits in either /usr/lib/systemd/system/ or /etc/systemd/system/ with the latter directory taking precedence.

    If you just wanted to have a service file then enable the unit systemctl enable rfxtrx.service. systemctl daemon-reload is used when the unit has already been registered with systemd and requires a reload.

    You can check if the service exists with systemd by using the command systemctl list-units or systemctl status rfxtrx.service.

    The error you have is that you're doing sudo systemctl start /etc/systemd/system/rfxtrx.service instead of sudo systemctl start rfxtrx.service.