source: chapter06/udev.xml@ 2fe5051a

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 6.3 6.4 6.5 6.6 6.7 6.8 7.0 7.1 7.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 2fe5051a was e4a5635, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Replaced "<" by "less than".

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@7612 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 13.4 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3 "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
7
8<sect1 id="ch-system-udev" role="wrap">
9 <?dbhtml filename="udev.html"?>
10
11 <title>Udev-&udev-version;</title>
12
13 <indexterm zone="ch-system-udev">
14 <primary sortas="a-Udev">Udev</primary>
15 </indexterm>
16
17 <sect2 role="package">
18 <title/>
19
20 <para>The Udev package contains programs for dynamic creation of device
21 nodes.</para>
22
23 <segmentedlist>
24 <segtitle>&buildtime;</segtitle>
25 <segtitle>&diskspace;</segtitle>
26
27 <seglistitem>
28 <seg>&udev-ch6-sbu;</seg>
29 <seg>&udev-ch6-du;</seg>
30 </seglistitem>
31 </segmentedlist>
32
33 </sect2>
34
35 <sect2 role="installation">
36 <title>Installation of Udev</title>
37
38 <para>The udev-config tarball contains LFS-specific files used to configure
39 Udev.</para>
40
41<screen><userinput>tar xf ../&udev-config;.tar.bz2</userinput></screen>
42
43 <para>Create some devices and directories that Udev cannot handle due to
44 them being required very early in the boot process:</para>
45
46<screen><userinput>install -dv /lib/{firmware,udev/devices/{pts,shm}}
47mknod -m0666 /lib/udev/devices/null c 1 3
48ln -sv /proc/self/fd /lib/udev/devices/fd
49ln -sv /proc/self/fd/0 /lib/udev/devices/stdin
50ln -sv /proc/self/fd/1 /lib/udev/devices/stdout
51ln -sv /proc/self/fd/2 /lib/udev/devices/stderr
52ln -sv /proc/kcore /lib/udev/devices/core</userinput></screen>
53
54 <para>Compile the package:</para>
55
56<screen><userinput>make EXTRAS="extras/ata_id extras/cdrom_id extras/edd_id \
57 extras/firmware extras/floppy extras/path_id \
58 extras/scsi_id extras/usb_id extras/volume_id"</userinput></screen>
59
60 <variablelist>
61 <title>The meaning of the make option:</title>
62
63 <varlistentry>
64 <term><parameter>EXTRAS=...</parameter></term>
65 <listitem>
66 <para>This builds several helper binaries that can aid in writing custom
67 Udev rules.</para>
68 </listitem>
69 </varlistentry>
70
71 </variablelist>
72
73 <para>To test the results, issue:
74 <userinput>make test</userinput>.</para>
75
76 <para>Install the package:</para>
77
78<screen><userinput>make DESTDIR=/ \
79 EXTRAS="extras/ata_id extras/cdrom_id extras/edd_id \
80 extras/firmware extras/floppy extras/path_id \
81 extras/scsi_id extras/usb_id extras/volume_id" install</userinput></screen>
82
83 <variablelist>
84 <title>The meaning of the make parameter:</title>
85
86 <varlistentry>
87 <term><parameter>DESTDIR=/</parameter></term>
88 <listitem>
89 <para>This prevents the Udev build process from killing any
90 <command>udevd</command> processes that may be running on the
91 host system.</para>
92 </listitem>
93 </varlistentry>
94
95 </variablelist>
96
97 <para>Udev's configuration is far from ideal by default, so install
98 the configuration files here:</para>
99
100<!-- FIXME: 90-bug.rules should be removed from the tarball once the book is released -->
101<screen><userinput>cp -v &udev-config;/[0-9]* /etc/udev/rules.d/</userinput></screen>
102
103 <para>Now install a helper script that is not included in the main Udev
104 tarball:</para>
105
106<screen><userinput>install -v -m 744 &udev-config;/write_cd_aliases /lib/udev/</userinput></screen>
107
108 <para>Install the documentation that explains how to create Udev rules:</para>
109
110<screen><userinput>install -m644 -D -v docs/writing_udev_rules/index.html \
111 /usr/share/doc/udev-&udev-version;/index.html</userinput></screen>
112
113 <important>
114
115 <para>When Udev is started by the LFS-Bootscripts, a replay of all kernel
116 device events happens. These events tell Udev what devices exist.
117 Sometimes the Udev bootscript doesn't wait long enough for
118 <command>udevd</command> to process all of the replayed events and
119 consequently the devices for those missed events are not created before the
120 script exits. Since <command>udevd</command> is still running in the
121 background, the devices will be created a few milliseconds later, but the
122 next bootscript to run may require a device to exist before it has been
123 created. To avoid such missed events, and to avoid hardcoding an overly
124 long wait time, It is recommended that you run the following commands to
125 aid the LFS development team in debugging these missed events and finding
126 an acceptable solution more quickly.</para>
127
128 <para>First, create a simple C file:</para>
129
130<screen><userinput>cat &gt; bug.c &lt;&lt; EOF
131<literal>/* Simple event recorder */
132#define _GNU_SOURCE
133#include &lt;sys/types.h&gt;
134#include &lt;sys/stat.h&gt;
135#include &lt;fcntl.h&gt;
136#include &lt;unistd.h&gt;
137#include &lt;stdlib.h&gt;
138#include &lt;argz.h&gt;
139int main(int argc, char * argv[])
140{
141 char * envar;
142 char * envz;
143 size_t len;
144 int bug;
145 bug = open("/dev/bug", O_WRONLY | O_APPEND);
146 if (bug == -1)
147 return 0;
148
149 /* Ignore everything USB-related to avoid spamming the list */
150 envar = getenv("PHYSDEVPATH");
151 if (envar &amp;&amp; strstr(envar, "usb"))
152 return 0;
153 envar = getenv("DEVPATH");
154 if (envar &amp;&amp; strstr(envar, "usb"))
155 return 0;
156
157 setenv("_SEPARATOR", "-------------------------------", 1);
158 argz_create(environ, &amp;envz, &amp;len);
159 argz_stringify(envz, len, '\n');
160 envz[len-1]='\n';
161 write(bug, envz, len);
162 close(bug);
163 free(envz);
164 return 0;
165}</literal>
166EOF</userinput></screen>
167
168 <para>Now compile it:</para>
169
170<screen><userinput>gcc -o /lib/udev/bug bug.c</userinput></screen>
171
172 <para>When booting the new LFS system, if any events are missed, a warning
173 message will appear and a <filename>/dev/bugreport</filename> file will be
174 created. The warning message will tell you where to send feedback.</para>
175
176 </important>
177
178 </sect2>
179
180 <sect2 id="contents-udev" role="content">
181 <title>Contents of Udev</title>
182
183 <segmentedlist>
184 <segtitle>Installed programs</segtitle>
185 <segtitle>Installed directory</segtitle>
186
187 <seglistitem>
188 <seg>ata_id, cdrom_id, create_floppy_devices, edd_id, firmware_helper,
189 path_id, scsi_id, udevcontrol, udevd, udevinfo, udevmonitor, udevsettle,
190 udevtest, udevtrigger, usb_id, vol_id, and write_cd_aliases</seg>
191 <seg>/etc/udev</seg>
192 </seglistitem>
193 </segmentedlist>
194
195 <variablelist>
196 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
197 <?dbfo list-presentation="list"?>
198 <?dbhtml list-presentation="table"?>
199
200 <varlistentry id="ata_id">
201 <term><command>ata_id</command></term>
202 <listitem>
203 <para>Provides Udev with a unique string and
204 additional information (uuid, label) for an ATA drive</para>
205 <indexterm zone="ch-system-udev ata_id">
206 <primary sortas="b-ata_id">ata_id</primary>
207 </indexterm>
208 </listitem>
209 </varlistentry>
210
211 <varlistentry id="cdrom_id">
212 <term><command>cdrom_id</command></term>
213 <listitem>
214 <para>Provides Udev with the capabilities of a
215 CD-ROM or DVD-ROM drive</para>
216 <indexterm zone="ch-system-udev cdrom_id">
217 <primary sortas="b-cdrom_id">cdrom_id</primary>
218 </indexterm>
219 </listitem>
220 </varlistentry>
221
222 <varlistentry id="create_floppy_devices">
223 <term><command>create_floppy_devices</command></term>
224 <listitem>
225 <para>Creates all possible floppy devices based on the CMOS type</para>
226 <indexterm zone="ch-system-udev create_floppy_devices">
227 <primary sortas="b-create_floppy_devices">create_floppy_devices</primary>
228 </indexterm>
229 </listitem>
230 </varlistentry>
231
232 <varlistentry id="edd_id">
233 <term><command>edd_id</command></term>
234 <listitem>
235 <para>Provides Udev with the EDD ID for a BIOS disk drive</para>
236 <indexterm zone="ch-system-udev edd_id">
237 <primary sortas="b-edd_id">edd_id</primary>
238 </indexterm>
239 </listitem>
240 </varlistentry>
241
242 <varlistentry id="firmware_helper">
243 <term><command>firmware_helper</command></term>
244 <listitem>
245 <para>Uploads firmware to devices</para>
246 <indexterm zone="ch-system-udev firmware_helper">
247 <primary sortas="b-firmware_helper">firmware_helper</primary>
248 </indexterm>
249 </listitem>
250 </varlistentry>
251
252 <varlistentry id="path_id">
253 <term><command>path_id</command></term>
254 <listitem>
255 <para>Provide the shortest possible unique hardware path to a
256 device</para>
257 <indexterm zone="ch-system-udev path_id">
258 <primary sortas="b-path_id">path_id</primary>
259 </indexterm>
260 </listitem>
261 </varlistentry>
262
263 <varlistentry id="scsi_id">
264 <term><command>scsi_id</command></term>
265 <listitem>
266 <para>Provides Udev with a unique SCSI identifier
267 based on the data returned from sending a SCSI INQUIRY command to
268 the specified device</para>
269 <indexterm zone="ch-system-udev scsi_id">
270 <primary sortas="b-scsi_id">scsi_id</primary>
271 </indexterm>
272 </listitem>
273 </varlistentry>
274
275 <varlistentry id="udevcontrol">
276 <term><command>udevcontrol</command></term>
277 <listitem>
278 <para>Configures a number of options for the running
279 <command>udevd</command> daemon, such as the log level.</para>
280 <indexterm zone="ch-system-udev udevcontrol">
281 <primary sortas="b-udevcontrol">udevcontrol</primary>
282 </indexterm>
283 </listitem>
284 </varlistentry>
285
286 <varlistentry id="udevd">
287 <term><command>udevd</command></term>
288 <listitem>
289 <para>A daemon that listens for uevents on the netlink socket,
290 creates devices and runs the configured external programs in
291 response to these uevents</para>
292 <indexterm zone="ch-system-udev udevd">
293 <primary sortas="b-udevd">udevd</primary>
294 </indexterm>
295 </listitem>
296 </varlistentry>
297
298 <varlistentry id="udevinfo">
299 <term><command>udevinfo</command></term>
300 <listitem>
301 <para>Allows users to query the Udev database for
302 information on any device currently present on the system; it also
303 provides a way to query any device in the <systemitem
304 class="filesystem">sysfs</systemitem> tree to help create udev
305 rules</para>
306 <indexterm zone="ch-system-udev udevinfo">
307 <primary sortas="b-udevinfo">udevinfo</primary>
308 </indexterm>
309 </listitem>
310 </varlistentry>
311
312 <varlistentry id="udevmonitor">
313 <term><command>udevmonitor</command></term>
314 <listitem>
315 <para>Prints the event received from the kernel and the environment
316 which Udev sends out after rule processing</para>
317 <indexterm zone="ch-system-udev udevmonitor">
318 <primary sortas="b-udevmonitor">udevmonitor</primary>
319 </indexterm>
320 </listitem>
321 </varlistentry>
322
323 <varlistentry id="udevsettle">
324 <term><command>udevsettle</command></term>
325 <listitem>
326 <para>Watches the Udev event queue and exits if all current uevents
327 have been handled</para>
328 <indexterm zone="ch-system-udev udevsettle">
329 <primary sortas="b-udevsettle">udevsettle</primary>
330 </indexterm>
331 </listitem>
332 </varlistentry>
333
334 <varlistentry id="udevtest">
335 <term><command>udevtest</command></term>
336 <listitem>
337 <para>Simulates a uevent for the given device, and prints out the
338 name of the node the real <command>udevd</command> would have created,
339 or the name of the renamed network interface</para>
340 <indexterm zone="ch-system-udev udevtest">
341 <primary sortas="b-udevtest">udevtest</primary>
342 </indexterm>
343 </listitem>
344 </varlistentry>
345
346 <varlistentry id="udevtrigger">
347 <term><command>udevtrigger</command></term>
348 <listitem>
349 <para>Triggers kernel device uevents to be replayed</para>
350 <indexterm zone="ch-system-udev udevtrigger">
351 <primary sortas="b-udevtrigger">udevtrigger</primary>
352 </indexterm>
353 </listitem>
354 </varlistentry>
355
356 <varlistentry id="usb_id">
357 <term><command>usb_id</command></term>
358 <listitem>
359 <para>Provides Udev with information about USB
360 devices</para>
361 <indexterm zone="ch-system-udev usb_id">
362 <primary sortas="b-usb_id">usb_id</primary>
363 </indexterm>
364 </listitem>
365 </varlistentry>
366
367 <varlistentry id="vol_id">
368 <term><command>vol_id</command></term>
369 <listitem>
370 <para>Provides Udev with the label and uuid of a
371 filesystem</para>
372 <indexterm zone="ch-system-udev vol_id">
373 <primary sortas="b-vol_id">vol_id</primary>
374 </indexterm>
375 </listitem>
376 </varlistentry>
377
378 <varlistentry id="etc-udev">
379 <term><filename class="directory">/etc/udev</filename></term>
380 <listitem>
381 <para>Contains Udev configuation files,
382 device permissions, and rules for device naming</para>
383 <indexterm zone="ch-system-udev etc-udev">
384 <primary sortas="e-/etc/udev">/etc/udev</primary>
385 </indexterm>
386 </listitem>
387 </varlistentry>
388
389 </variablelist>
390
391 </sect2>
392
393</sect1>
Note: See TracBrowser for help on using the repository browser.