5

The documentation I have read on systemd unit files states that unit files can be found in three locations on the filesystem:

  1. /etc/systemd/system/: system unit files
  2. /run/systemd/system/: runtime unit files
  3. /lib/systemd/system/ (also sometimes /usr/lib/systemd/system/): default unit files for packages

I understand that system unit files are for (possibly user-configured) system daemons. I also understand that default package unit files are unit files that come along with package installs that provide sane defaults.

However, I cannot find documentation that explains the purpose of runtime unit files. What are runtime unit files for? Might I, as a sysadmin, ever create one? What are some examples of problems that might be solved with runtime unit files? Why do runtime unit files take precedence over package unit files, but not over system unit files?

2

4 Answers 4

1

Historically, runtime unit files are intended for machine-generated units. They are supposed to override corresponding vendor units (if any), but are designed to allow user overrides, hence the defined precedence.

Nowadays I think they’ve largely been supplanted by transient units generated using the bus API; these don’t appear as files anywhere.

0

I've never seen /run/systemd being used for unit files on my systems. Although it could be used when you're just running unmodified unit files from /lib/systemd.

Usually /lib/systemd contains the default unit files and timers (and you should never edit them there), and /etc/systemd contains the enabled (links to /lib/systemd files) and customized ones.

You can customize timers and unit files with sudo systemctl edit unit/timer to add some things to the original file or sudo systemctl edit --full unit/timer to completely edit the unit file or timer.

1
0

From reading the manual here it appears that runtime unit files are simply another type of systemd configuration file, for a given process.

Also, they are generated at runtime and deleted upon exiting the process.

If it helps, search "run" on that page and read all the entries. From there, it is easy to reach the same conclusion.

0

The runtime files in /run/systemd/system stem from the ability to make modifications to a process (unit) during the current boot without that change/modification persisting across a reboot.

From systemctl.1:

--runtime
           When used with enable, disable, edit, (and related commands),
           make changes only temporarily, so that they are lost on the
           next reboot. This will have the effect that changes are not
           made in subdirectories of /etc/ but in /run/, with identical
           immediate effects, however, since the latter is lost on
           reboot, the changes are lost too.

           Similarly, when used with set-property, make changes only
           temporarily, so that they are lost on the next reboot.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .