]>
Commit | Line | Data |
---|---|---|
eec575d8 | 1 | <?xml version='1.0'?> <!--*-nxml-*--> |
eec575d8 | 2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" |
12b42c76 | 3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> |
eec575d8 LP |
4 | |
5 | <!-- | |
572eb058 | 6 | SPDX-License-Identifier: LGPL-2.1+ |
eec575d8 LP |
7 | --> |
8 | ||
9 | <refentry id="systemd.device"> | |
798d3a52 ZJS |
10 | <refentryinfo> |
11 | <title>systemd.device</title> | |
12 | <productname>systemd</productname> | |
798d3a52 ZJS |
13 | </refentryinfo> |
14 | ||
15 | <refmeta> | |
16 | <refentrytitle>systemd.device</refentrytitle> | |
17 | <manvolnum>5</manvolnum> | |
18 | </refmeta> | |
19 | ||
20 | <refnamediv> | |
21 | <refname>systemd.device</refname> | |
22 | <refpurpose>Device unit configuration</refpurpose> | |
23 | </refnamediv> | |
24 | ||
25 | <refsynopsisdiv> | |
26 | <para><filename><replaceable>device</replaceable>.device</filename></para> | |
27 | </refsynopsisdiv> | |
28 | ||
29 | <refsect1> | |
30 | <title>Description</title> | |
31 | ||
32 | <para>A unit configuration file whose name ends in | |
33 | <literal>.device</literal> encodes information about a device unit | |
34 | as exposed in the | |
35 | sysfs/<citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry> | |
36 | device tree.</para> | |
37 | ||
38 | <para>This unit type has no specific options. See | |
39 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
40 | for the common options of all unit configuration files. The common | |
41 | configuration items are configured in the generic | |
42 | <literal>[Unit]</literal> and <literal>[Install]</literal> | |
43 | sections. A separate <literal>[Device]</literal> section does not | |
44 | exist, since no device-specific options may be configured.</para> | |
45 | ||
46 | <para>systemd will dynamically create device units for all kernel | |
47 | devices that are marked with the "systemd" udev tag (by default | |
48 | all block and network devices, and a few others). This may be used | |
49 | to define dependencies between devices and other units. To tag a | |
50 | udev device, use <literal>TAG+="systemd"</literal> in the udev | |
51 | rules file, see | |
52 | <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry> | |
53 | for details.</para> | |
54 | ||
55 | <para>Device units are named after the <filename>/sys</filename> | |
56 | and <filename>/dev</filename> paths they control. Example: the | |
57 | device <filename noindex='true'>/dev/sda5</filename> is exposed in | |
58 | systemd as <filename>dev-sda5.device</filename>. For details about | |
59 | the escaping logic used to convert a file system path to a unit | |
60 | name see | |
61 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para> | |
f332611a JR |
62 | |
63 | <para>Device units will be reloaded by systemd whenever the | |
64 | corresponding device generates a <literal>changed</literal> event. | |
65 | Other units can use <varname>ReloadPropagatedFrom=</varname> to react | |
66 | to that event</para> | |
c129bd5d | 67 | </refsect1> |
798d3a52 | 68 | |
c129bd5d | 69 | <refsect1> |
aed5cb03 | 70 | <title>Automatic Dependencies</title> |
798d3a52 | 71 | |
aed5cb03 ZJS |
72 | <refsect2> |
73 | <title>Implicit Dependencies</title> | |
74 | ||
75 | <para>Many unit types automatically acquire dependencies on device | |
76 | units of devices they require. For example, | |
77 | <filename>.socket</filename> unit acquire dependencies on the | |
78 | device units of the network interface specified in | |
79 | <varname>BindToDevice=</varname>. Similar, swap and mount units | |
80 | acquire dependencies on the units encapsulating their backing | |
81 | block devices.</para> | |
82 | </refsect2> | |
83 | ||
84 | <refsect2> | |
85 | <title>Default Dependencies</title> | |
45f09f93 | 86 | |
aed5cb03 ZJS |
87 | <para>There are no default dependencies for device units.</para> |
88 | </refsect2> | |
45f09f93 JL |
89 | </refsect1> |
90 | ||
798d3a52 ZJS |
91 | <refsect1> |
92 | <title>The udev Database</title> | |
93 | ||
dcebc9ba LP |
94 | <para>Unit settings of device units may either be configured via unit files, or directly from the udev |
95 | database. The following udev device properties are understood by the service manager:</para> | |
798d3a52 ZJS |
96 | |
97 | <variablelist class='udev-directives'> | |
98 | <varlistentry> | |
99 | <term><varname>SYSTEMD_WANTS=</varname></term> | |
100 | <term><varname>SYSTEMD_USER_WANTS=</varname></term> | |
dcebc9ba LP |
101 | <listitem><para>Adds dependencies of type <varname>Wants=</varname> from the device unit to the specified |
102 | units. <varname>SYSTEMD_WANTS=</varname> is read by the system service manager, | |
103 | <varname>SYSTEMD_USER_WANTS=</varname> by user service manager instances. These properties may be used to | |
104 | activate arbitrary units when a specific device becomes available.</para> | |
105 | ||
106 | <para>Note that this and the other udev device properties are not taken into account unless the device is | |
107 | tagged with the <literal>systemd</literal> tag in the udev database, because otherwise the device is not | |
108 | exposed as a systemd unit (see above).</para> | |
109 | ||
110 | <para>Note that systemd will only act on <varname>Wants=</varname> dependencies when a device first becomes | |
111 | active. It will not act on them if they are added to devices that are already active. Use | |
112 | <varname>SYSTEMD_READY=</varname> (see below) to configure when a udev device shall be considered active, and | |
113 | thus when to trigger the dependencies.</para> | |
114 | ||
115 | <!-- Note that we don't document here that we actually apply unit_name_mangle() to all specified names, since | |
116 | that's kinda ugly, and people should instead specify correctly escaped names --> | |
117 | ||
118 | <para>The specified property value should be a space-separated list of valid unit names. If a unit template | |
119 | name is specified (that is, a unit name containing an <literal>@</literal> character indicating a unit name to | |
120 | use for multiple instantiation, but with an empty instance name following the <literal>@</literal>), it will be | |
121 | automatically instantiated by the device's <literal>sysfs</literal> path (that is: the path is escaped and | |
122 | inserted as instance name into the template unit name). This is useful in order to instantiate a specific | |
123 | template unit once for each device that appears and matches specific properties.</para></listitem> | |
798d3a52 ZJS |
124 | </varlistentry> |
125 | ||
126 | <varlistentry> | |
127 | <term><varname>SYSTEMD_ALIAS=</varname></term> | |
128 | <listitem><para>Adds an additional alias name to the device | |
129 | unit. This must be an absolute path that is automatically | |
130 | transformed into a unit name. (See above.)</para></listitem> | |
131 | </varlistentry> | |
132 | ||
133 | <varlistentry> | |
134 | <term><varname>SYSTEMD_READY=</varname></term> | |
dcebc9ba LP |
135 | <listitem><para>If set to 0, systemd will consider this device unplugged even if it shows up in the udev |
136 | tree. If this property is unset or set to 1, the device will be considered plugged if it is visible in the udev | |
137 | tree.</para> | |
138 | ||
139 | <para>This option is useful for devices that initially show up in an uninitialized state in the tree, and for | |
140 | which a <literal>changed</literal> event is generated the moment they are fully set up. Note that | |
141 | <varname>SYSTEMD_WANTS=</varname> (see above) is not acted on as long as <varname>SYSTEMD_READY=0</varname> is | |
142 | set for a device.</para></listitem> | |
798d3a52 ZJS |
143 | </varlistentry> |
144 | ||
145 | <varlistentry> | |
146 | <term><varname>ID_MODEL_FROM_DATABASE=</varname></term> | |
147 | <term><varname>ID_MODEL=</varname></term> | |
148 | ||
149 | <listitem><para>If set, this property is used as description | |
150 | string for the device unit.</para></listitem> | |
151 | </varlistentry> | |
152 | ||
153 | </variablelist> | |
154 | ||
155 | </refsect1> | |
156 | ||
157 | <refsect1> | |
158 | <title>See Also</title> | |
159 | <para> | |
160 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
161 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
162 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
163 | <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry>, | |
164 | <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry> | |
165 | </para> | |
166 | </refsect1> | |
eec575d8 LP |
167 | |
168 | </refentry> |