]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd.device.xml
device : reload when udev generates a "changed" event
[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>Automatic 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>The udev Database</title>
108
109 <para>The settings of device units may either be configured via
110 unit files, or directly from the udev database (which is
111 recommended). The following udev device properties are understood
112 by systemd:</para>
113
114 <variablelist class='udev-directives'>
115 <varlistentry>
116 <term><varname>SYSTEMD_WANTS=</varname></term>
117 <term><varname>SYSTEMD_USER_WANTS=</varname></term>
118 <listitem><para>Adds dependencies of type
119 <varname>Wants</varname> from the device unit to all listed
120 units. The first form is used by the system systemd instance,
121 the second by user systemd instances. Those settings may be
122 used to activate arbitrary units when a specific device
123 becomes available.</para>
124
125 <para>Note that this and the other tags are not taken into
126 account unless the device is tagged with the
127 <literal>systemd</literal> string in the udev database,
128 because otherwise the device is not exposed as a systemd unit
129 (see above).</para>
130
131 <para>Note that systemd will only act on
132 <varname>Wants</varname> dependencies when a device first
133 becomes active. It will not act on them if they are added to
134 devices that are already active. Use
135 <varname>SYSTEMD_READY=</varname> (see below) to influence on
136 which udev event to trigger the dependencies.
137 </para></listitem>
138 </varlistentry>
139
140 <varlistentry>
141 <term><varname>SYSTEMD_ALIAS=</varname></term>
142 <listitem><para>Adds an additional alias name to the device
143 unit. This must be an absolute path that is automatically
144 transformed into a unit name. (See above.)</para></listitem>
145 </varlistentry>
146
147 <varlistentry>
148 <term><varname>SYSTEMD_READY=</varname></term>
149 <listitem><para>If set to 0, systemd will consider this device
150 unplugged even if it shows up in the udev tree. If this
151 property is unset or set to 1, the device will be considered
152 plugged if it is visible in the udev tree. This property has
153 no influence on the behavior when a device disappears from the
154 udev tree.</para>
155
156 <para>This option is useful to support devices that initially
157 show up in an uninitialized state in the tree, and for which a
158 <literal>changed</literal> event is generated the moment they
159 are fully set up. Note that <varname>SYSTEMD_WANTS=</varname>
160 (see above) is not acted on as long as
161 <varname>SYSTEMD_READY=0</varname> is set for a
162 device.</para></listitem>
163 </varlistentry>
164
165 <varlistentry>
166 <term><varname>ID_MODEL_FROM_DATABASE=</varname></term>
167 <term><varname>ID_MODEL=</varname></term>
168
169 <listitem><para>If set, this property is used as description
170 string for the device unit.</para></listitem>
171 </varlistentry>
172
173 </variablelist>
174
175 </refsect1>
176
177 <refsect1>
178 <title>See Also</title>
179 <para>
180 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
181 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
182 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
183 <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
184 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>
185 </para>
186 </refsect1>
187
188 </refentry>