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