source: chapter06/udev.xml@ 9cdcfb1

Last change on this file since 9cdcfb1 was 9cdcfb1, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Merged r7489 from trunk to udev_update branch.

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

  • Property mode set to 100644
File size: 12.3 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 <segmentedlist>
34 <segtitle>&dependencies;</segtitle>
35
36 <seglistitem>
37 <seg>Coreutils, GCC, Make, and Perl</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 EXTRAS="extras/ata_id extras/cdrom_id extras/edd_id \
60 extras/firmware extras/floppy extras/scsi_id \
61 extras/usb_id extras/volume_id"</userinput></screen>
62
63 <variablelist>
64 <title>The meaning of the make option:</title>
65
66 <varlistentry>
67 <term><parameter>EXTRAS=...</parameter></term>
68 <listitem>
69 <para>This builds several helper binaries that can aid in writing custom
70 Udev rules.</para>
71 </listitem>
72 </varlistentry>
73
74 </variablelist>
75
76 <para>To test the results, issue:
77 <userinput>make test</userinput>.</para>
78
79 <para>Install the package:</para>
80
81<screen><userinput>make DESTDIR=/ \
82 EXTRAS="extras/ata_id extras/cdrom_id extras/edd_id \
83 extras/firmware extras/floppy extras/scsi_id \
84 extras/usb_id extras/volume_id" install</userinput></screen>
85
86 <variablelist>
87 <title>The meaning of the make parameter:</title>
88
89 <varlistentry>
90 <term><parameter>DESTDIR=/</parameter></term>
91 <listitem>
92 <para>This prevents the Udev build process from killing any
93 <command>udevd</command> processes that may be running on the
94 host system.</para>
95 </listitem>
96 </varlistentry>
97
98 </variablelist>
99
100 <para>Udev's configuration is far from ideal by default, so install
101 the configuration files here:</para>
102
103<screen><userinput>cp -v ../&udev-config-file; /etc/udev/rules.d/25-lfs.rules</userinput></screen>
104
105 <para>Create some rules that work around broken sysfs attribute creation
106 timing in linux-2.6.15:</para>
107
108<screen><userinput>cat &gt;&gt; /etc/udev/rules.d/10-wait_for_sysfs.rules &lt;&lt; "EOF"
109ACTION=="add", DEVPATH=="/devices/*", ENV{PHYSDEVBUS}=="?*", WAIT_FOR_SYSFS="bus"
110ACTION=="add", SUBSYSTEM=="net", WAIT_FOR_SYSFS="address"
111EOF</userinput></screen>
112
113 <para>Install the documentation that explains how to create Udev rules:</para>
114
115<screen><userinput>install -m644 -D -v docs/writing_udev_rules/index.html /usr/share/doc/udev-&udev-version;/index.html</userinput></screen>
116
117 <important>
118
119 <para>When Udev is started by the LFS-Bootscripts, a replay of all kernel
120 device events happens. These events tell Udev what devices exist.
121 Sometimes the Udev bootscript doesn't wait long enough for
122 <command>udevd</command> to process all of the replayed events and
123 consequently the devices for those missed events are not created before the
124 script exits. Since <command>udevd</command> is still running in the
125 background, the devices will be created a few milliseconds later, but the
126 next bootscript to run may require a device to exist before it has been
127 created. To avoid such missed events, and to avoid hardcoding an overly
128 long wait time, It is recommended that you run the following commands to
129 aide the LFS development team in debugging these missed events and finding
130 an acceptable solution more quickly.</para>
131
132 <para>First, create a simple C file:</para>
133
134<screen><userinput>cat &gt; bug.c &lt;&lt; EOF
135<literal>/* Simple event recorder */
136#define _GNU_SOURCE
137#include &lt;sys/types.h&gt;
138#include &lt;sys/stat.h&gt;
139#include &lt;fcntl.h&gt;
140#include &lt;unistd.h&gt;
141#include &lt;stdlib.h&gt;
142#include &lt;argz.h&gt;
143int main(int argc, char * argv[])
144{
145 char * envz;
146 size_t len;
147 int bug;
148 bug = open("/dev/bug", O_WRONLY | O_APPEND);
149 if (bug == -1)
150 return 0;
151 setenv("_SEPARATOR", "--------------------------------------", 1);
152 argz_create(environ, &amp;envz, &amp;len);
153 argz_stringify(envz, len, '\n');
154 envz[len-1]='\n';
155 write(bug, envz, len);
156 close(bug);
157 free(envz);
158 return 0;
159}</literal>
160EOF</userinput></screen>
161
162 <para>Now compile it:</para>
163
164<screen><userinput>gcc -o /lib/udev/bug bug.c</userinput></screen>
165
166 <para>The next step adds a simple logging rule to run this program.</para>
167
168<screen><userinput>cat &gt; /etc/udev/rules.d/90-bug.rules &lt;&lt; "EOF"
169<literal>ACTION=="add", RUN+="bug"</literal>
170EOF</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 scsi_id, udevcontrol, udevd, udevinfo, udevmonitor, udevtest, usb_id
190 and vol_id</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="scsi_id">
253 <term><command>scsi_id</command></term>
254 <listitem>
255 <para>Provides Udev 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 listens for uevents on the netlink socket,
279 creates devices and runs the configured external programs in
280 response to these uevents</para>
281 <indexterm zone="ch-system-udev udevd">
282 <primary sortas="b-udevd">udevd</primary>
283 </indexterm>
284 </listitem>
285 </varlistentry>
286
287 <varlistentry id="udevinfo">
288 <term><command>udevinfo</command></term>
289 <listitem>
290 <para>Allows users to query the Udev database for
291 information on any device currently present on the system; it also
292 provides a way to query any device in the <systemitem
293 class="filesystem">sysfs</systemitem> tree to help create udev
294 rules</para>
295 <indexterm zone="ch-system-udev udevinfo">
296 <primary sortas="b-udevinfo">udevinfo</primary>
297 </indexterm>
298 </listitem>
299 </varlistentry>
300
301 <varlistentry id="udevmonitor">
302 <term><command>udevmonitor</command></term>
303 <listitem>
304 <para>Prints the event received from the kernel and the environment
305 which Udev sends out after rule processing</para>
306 <indexterm zone="ch-system-udev udevmonitor">
307 <primary sortas="b-udevmonitor">udevmonitor</primary>
308 </indexterm>
309 </listitem>
310 </varlistentry>
311
312 <varlistentry id="udevtest">
313 <term><command>udevtest</command></term>
314 <listitem>
315 <para>Simulates a uevent for the given device, and prints out the
316 name of the node the real <command>udevd</command> would have created,
317 or the name of the renamed network 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 Udev 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 Udev 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 Udev 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.