source: chapter06/udev.xml@ 9f0158c

Last change on this file since 9f0158c was 9f0158c, checked in by Archaic <archaic@…>, 19 years ago

Updated the bootscripts. Removed references to hotplug and the
bootscripts udev patch. Removed reference to udevstart. Added
text and commands for generating Udev bug reports.

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

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