udev.xml 12 KB

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