[9dfc02f] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[ddd5542] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
|
---|
[9dfc02f] | 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
[ddd5542] | 7 |
|
---|
[a001133] | 8 | <sect1 id="ch-system-udev" role="wrap">
|
---|
[ddd5542] | 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/>
|
---|
[9dfc02f] | 19 |
|
---|
[ddd5542] | 20 | <para>The Udev package contains programs for dynamic creation of device
|
---|
| 21 | nodes.</para>
|
---|
[9dfc02f] | 22 |
|
---|
[ddd5542] | 23 | <segmentedlist>
|
---|
| 24 | <segtitle>&buildtime;</segtitle>
|
---|
| 25 | <segtitle>&diskspace;</segtitle>
|
---|
[9dfc02f] | 26 |
|
---|
[ddd5542] | 27 | <seglistitem>
|
---|
[e4a5635] | 28 | <seg>&udev-ch6-sbu;</seg>
|
---|
| 29 | <seg>&udev-ch6-du;</seg>
|
---|
[ddd5542] | 30 | </seglistitem>
|
---|
| 31 | </segmentedlist>
|
---|
[9dfc02f] | 32 |
|
---|
[ddd5542] | 33 | </sect2>
|
---|
[9dfc02f] | 34 |
|
---|
[ddd5542] | 35 | <sect2 role="installation">
|
---|
| 36 | <title>Installation of Udev</title>
|
---|
| 37 |
|
---|
[7d6d34b] | 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 |
|
---|
[d2c332bc] | 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}}
|
---|
| 47 | mknod -m0666 /lib/udev/devices/null c 1 3
|
---|
| 48 | ln -sv /proc/self/fd /lib/udev/devices/fd
|
---|
| 49 | ln -sv /proc/self/fd/0 /lib/udev/devices/stdin
|
---|
| 50 | ln -sv /proc/self/fd/1 /lib/udev/devices/stdout
|
---|
| 51 | ln -sv /proc/self/fd/2 /lib/udev/devices/stderr
|
---|
| 52 | ln -sv /proc/kcore /lib/udev/devices/core</userinput></screen>
|
---|
| 53 |
|
---|
[ddd5542] | 54 | <para>Compile the package:</para>
|
---|
[9dfc02f] | 55 |
|
---|
[d2c332bc] | 56 | <screen><userinput>make EXTRAS="extras/ata_id extras/cdrom_id extras/edd_id \
|
---|
[7d6d34b] | 57 | extras/firmware extras/floppy extras/path_id \
|
---|
| 58 | extras/scsi_id extras/usb_id extras/volume_id"</userinput></screen>
|
---|
[81fd230] | 59 |
|
---|
[ddd5542] | 60 | <variablelist>
|
---|
| 61 | <title>The meaning of the make option:</title>
|
---|
| 62 |
|
---|
| 63 | <varlistentry>
|
---|
[d2c332bc] | 64 | <term><parameter>EXTRAS=...</parameter></term>
|
---|
[ddd5542] | 65 | <listitem>
|
---|
[d2c332bc] | 66 | <para>This builds several helper binaries that can aid in writing custom
|
---|
| 67 | Udev rules.</para>
|
---|
[ddd5542] | 68 | </listitem>
|
---|
| 69 | </varlistentry>
|
---|
[09043c0] | 70 |
|
---|
[ddd5542] | 71 | </variablelist>
|
---|
[09043c0] | 72 |
|
---|
[ddd5542] | 73 | <para>To test the results, issue:
|
---|
| 74 | <userinput>make test</userinput>.</para>
|
---|
[81fd230] | 75 |
|
---|
[ddd5542] | 76 | <para>Install the package:</para>
|
---|
[9dfc02f] | 77 |
|
---|
[d2c332bc] | 78 | <screen><userinput>make DESTDIR=/ \
|
---|
| 79 | EXTRAS="extras/ata_id extras/cdrom_id extras/edd_id \
|
---|
[7d6d34b] | 80 | extras/firmware extras/floppy extras/path_id \
|
---|
| 81 | extras/scsi_id extras/usb_id extras/volume_id" install</userinput></screen>
|
---|
[09043c0] | 82 |
|
---|
[ddd5542] | 83 | <variablelist>
|
---|
| 84 | <title>The meaning of the make parameter:</title>
|
---|
[09043c0] | 85 |
|
---|
[ddd5542] | 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>
|
---|
[9dfc02f] | 94 |
|
---|
[ddd5542] | 95 | </variablelist>
|
---|
| 96 |
|
---|
| 97 | <para>Udev's configuration is far from ideal by default, so install
|
---|
| 98 | the configuration files here:</para>
|
---|
[18da154] | 99 |
|
---|
[3c19a9a] | 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>
|
---|
[18da154] | 102 |
|
---|
[7d6d34b] | 103 | <para>Now install a helper script that is not included in the main Udev
|
---|
| 104 | tarball:</para>
|
---|
[d2c332bc] | 105 |
|
---|
[3c19a9a] | 106 | <screen><userinput>install -v -m 744 &udev-config;/write_cd_aliases /lib/udev/</userinput></screen>
|
---|
[d2c332bc] | 107 |
|
---|
[ddd5542] | 108 | <para>Install the documentation that explains how to create Udev rules:</para>
|
---|
[7eac3e32] | 109 |
|
---|
[2c558d69] | 110 | <screen><userinput>install -m644 -D -v docs/writing_udev_rules/index.html \
|
---|
| 111 | /usr/share/doc/udev-&udev-version;/index.html</userinput></screen>
|
---|
[7eac3e32] | 112 |
|
---|
[d2c332bc] | 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 > bug.c << EOF
|
---|
| 131 | <literal>/* Simple event recorder */
|
---|
| 132 | #define _GNU_SOURCE
|
---|
| 133 | #include <sys/types.h>
|
---|
| 134 | #include <sys/stat.h>
|
---|
| 135 | #include <fcntl.h>
|
---|
| 136 | #include <unistd.h>
|
---|
| 137 | #include <stdlib.h>
|
---|
| 138 | #include <argz.h>
|
---|
| 139 | int main(int argc, char * argv[])
|
---|
| 140 | {
|
---|
[8abeb3b] | 141 | char * envar;
|
---|
[d2c332bc] | 142 | char * envz;
|
---|
| 143 | size_t len;
|
---|
| 144 | int bug;
|
---|
| 145 | bug = open("/dev/bug", O_WRONLY | O_APPEND);
|
---|
| 146 | if (bug == -1)
|
---|
[8abeb3b] | 147 | return 0;
|
---|
| 148 |
|
---|
| 149 | /* Ignore everything USB-related to avoid spamming the list */
|
---|
| 150 | envar = getenv("PHYSDEVPATH");
|
---|
| 151 | if (envar && strstr(envar, "usb"))
|
---|
| 152 | return 0;
|
---|
| 153 | envar = getenv("DEVPATH");
|
---|
| 154 | if (envar && strstr(envar, "usb"))
|
---|
| 155 | return 0;
|
---|
| 156 |
|
---|
[2c558d69] | 157 | setenv("_SEPARATOR", "-------------------------------", 1);
|
---|
[d2c332bc] | 158 | argz_create(environ, &envz, &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>
|
---|
| 166 | EOF</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>
|
---|
[6135b95] | 177 |
|
---|
[ddd5542] | 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>
|
---|
[d2c332bc] | 188 | <seg>ata_id, cdrom_id, create_floppy_devices, edd_id, firmware_helper,
|
---|
[7d6d34b] | 189 | path_id, scsi_id, udevcontrol, udevd, udevinfo, udevmonitor, udevsettle,
|
---|
| 190 | udevtest, udevtrigger, usb_id, vol_id, and write_cd_aliases</seg>
|
---|
[ddd5542] | 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 |
|
---|
[d2c332bc] | 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>
|
---|
[ddd5542] | 224 | <listitem>
|
---|
[d2c332bc] | 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>
|
---|
[ddd5542] | 228 | </indexterm>
|
---|
| 229 | </listitem>
|
---|
| 230 | </varlistentry>
|
---|
| 231 |
|
---|
[d2c332bc] | 232 | <varlistentry id="edd_id">
|
---|
| 233 | <term><command>edd_id</command></term>
|
---|
[ddd5542] | 234 | <listitem>
|
---|
[d2c332bc] | 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>
|
---|
[ddd5542] | 238 | </indexterm>
|
---|
| 239 | </listitem>
|
---|
| 240 | </varlistentry>
|
---|
| 241 |
|
---|
[d2c332bc] | 242 | <varlistentry id="firmware_helper">
|
---|
| 243 | <term><command>firmware_helper</command></term>
|
---|
[ddd5542] | 244 | <listitem>
|
---|
[d2c332bc] | 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 |
|
---|
[7d6d34b] | 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 |
|
---|
[d2c332bc] | 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>
|
---|
[ddd5542] | 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>
|
---|
[d2c332bc] | 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>
|
---|
[ddd5542] | 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>
|
---|
[d2c332bc] | 301 | <para>Allows users to query the Udev database for
|
---|
[ddd5542] | 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>
|
---|
[d2c332bc] | 315 | <para>Prints the event received from the kernel and the environment
|
---|
| 316 | which Udev sends out after rule processing</para>
|
---|
[ddd5542] | 317 | <indexterm zone="ch-system-udev udevmonitor">
|
---|
| 318 | <primary sortas="b-udevmonitor">udevmonitor</primary>
|
---|
| 319 | </indexterm>
|
---|
| 320 | </listitem>
|
---|
| 321 | </varlistentry>
|
---|
| 322 |
|
---|
[7d6d34b] | 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 |
|
---|
[d2c332bc] | 334 | <varlistentry id="udevtest">
|
---|
| 335 | <term><command>udevtest</command></term>
|
---|
[ddd5542] | 336 | <listitem>
|
---|
[d2c332bc] | 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>
|
---|
[ddd5542] | 342 | </indexterm>
|
---|
| 343 | </listitem>
|
---|
| 344 | </varlistentry>
|
---|
| 345 |
|
---|
[7d6d34b] | 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 |
|
---|
[d2c332bc] | 356 | <varlistentry id="usb_id">
|
---|
| 357 | <term><command>usb_id</command></term>
|
---|
[ddd5542] | 358 | <listitem>
|
---|
[d2c332bc] | 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>
|
---|
[ddd5542] | 363 | </indexterm>
|
---|
| 364 | </listitem>
|
---|
| 365 | </varlistentry>
|
---|
| 366 |
|
---|
[d2c332bc] | 367 | <varlistentry id="vol_id">
|
---|
| 368 | <term><command>vol_id</command></term>
|
---|
[ddd5542] | 369 | <listitem>
|
---|
[d2c332bc] | 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>
|
---|
[ddd5542] | 374 | </indexterm>
|
---|
| 375 | </listitem>
|
---|
| 376 | </varlistentry>
|
---|
| 377 |
|
---|
| 378 | <varlistentry id="etc-udev">
|
---|
| 379 | <term><filename class="directory">/etc/udev</filename></term>
|
---|
| 380 | <listitem>
|
---|
[d2c332bc] | 381 | <para>Contains Udev configuation files,
|
---|
[ddd5542] | 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>
|
---|
[9dfc02f] | 392 |
|
---|
| 393 | </sect1>
|
---|