udev.xml 12 KB

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