How can I make a modification to a .service and keep it persistent?

You should override the unit with a unit in /etc. The easiest way to do this is to use systemctl edit:

sudo systemctl edit transmission-daemon

will open an editor and allow you to create a override snippet.

An override snippet ensures that future changes to the package’s unit (in /lib) are taken into account: the reference will be the package’s unit, with your overrides applied on top. All you need to use this in your case is a .conf file in /etc/systemd/system/transmission-daemon.service.d/, containing only the section and RequiresMountsFor line. systemctl edit will do this for you, creating an override.conf file in the appropriate location.

Alternatively, you can copy the full /lib/systemd/system/transmission-daemon.service unit to /etc/systemd/system and edit that. Again, systemctl edit can take care of this for you, with the --full option.

Look for “Example 2. Overriding vendor settings” in the systemd.unit documentation for details.


Copy it to /etc/systemd (or an appropriate sub-directory of /etc/systemd) and modify the copy.

/lib/systemd is for packaged unit files. They will get overwritten when systemd (or whatever package provides them) is upgraded.

/etc/systemd is for your own and for customised unit files. Unit files you place in here will override the package-provided file and will not be replaced on upgrade.

Tags:

Systemd