source: chapter06/udev.xml@ c7dfdfb9

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 12.2 12.2-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/loongarch-12.2 xry111/mips64el xry111/multilib xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since c7dfdfb9 was 72d7e28, checked in by Jeremy Huntwork <jhuntwork@…>, 18 years ago

Moved all dependency information to a new page, Appendix C.
Appendix C also contains information concerning the build order.
While there might need to be a few tweaks yet, this information is complete
enough at this point to close out the long-standing ticket #684.
Many thanks to Chris Staub, Dan Nicholson and Manuel Canales Esparcia for
helping get this finished.

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

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