Ignore:
Timestamp:
May 28, 2014, 12:57:40 AM (11 years ago)
Author:
Chris Staub <chris@…>
Branches:
clfs-3.0.0-systemd, master, systemd
Children:
f35f6d9
Parents:
7874109
Message:

More updates to udev explanation page

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BOOK/system-config/common/udev.xml

    r7874109 rf38842d  
    2929      <para>Linux systems in general traditionally use a static device creation
    3030      method, whereby a great many device nodes are created under <filename
    31       class="directory">/dev</filename> (sometimes literally thousands of nodes),
    32       regardless of whether the corresponding hardware devices actually exist.
    33       This is typically done via a <command>MAKEDEV</command> script, which
    34       contains a number of calls to the <command>mknod</command> program with the
    35       relevant major and minor device numbers for every possible device that
    36       might exist in the world.</para>
     31      class="directory">/dev</filename> (sometimes literally thousands of
     32      nodes), regardless of whether the corresponding hardware devices actually
     33      exist. This is typically done via a <command>MAKEDEV</command> script,
     34      which contains a number of calls to the <command>mknod</command> program
     35      with the relevant major and minor device numbers for every possible
     36      device that might exist in the world.</para>
    3737
    3838    </sect3>
     
    4242
    4343      <para>In February 2000, a new filesystem called <systemitem
    44       class="filesystem">devfs</systemitem> was merged into the 2.3.46 kernel
    45       and was made available during the 2.4 series of stable kernels. Although
    46       it was present in the kernel source itself, this method of creating devices
    47       dynamically never received overwhelming support from the core kernel
    48       developers.</para>
     44      class="filesystem">devfs</systemitem>, which dynamically created device
     45      nodes as devices were found by the kernel, was merged into the
     46      2.3.46 kernel and was made available during the 2.4 series of stable
     47      kernels. Although it was present in the kernel source itself, this method
     48      of creating devices dynamically never received overwhelming support from
     49      the core kernel developers.</para>
    4950
    5051      <para>The main problem with the approach adopted by <systemitem
     
    5657      particular developer(s). The <systemitem
    5758      class="filesystem">devfs</systemitem> file system also suffered from race
    58       conditions that were inherent in its design and could not be fixed without a
    59       substantial revision to the kernel. It was marked deprecated with the
     59      conditions that were inherent in its design and could not be fixed without
     60      a substantial revision to the kernel. It was marked deprecated with the
    6061      release of the 2.6 kernel series, and was removed entirely as of version
    6162      2.6.18.</para>
     
    7879      class="directory">/sys</filename>), data which the built-in drivers
    7980      registered with <systemitem class="filesystem">sysfs</systemitem> are
    80       available to userspace processes. With this
    81       userspace-visible representation, the possibility of seeing a userspace
    82       replacement for <systemitem class="filesystem">devfs</systemitem> became
    83       much more realistic.</para>
     81      available to userspace processes. With this userspace-visible
     82      representation, the possibility of seeing a userspace replacement for
     83      <systemitem class="filesystem">devfs</systemitem> became much more
     84      realistic.</para>
    8485
    8586    </sect3>
     
    8889      <title>Udev Implementation</title>
    8990
    90 <!--      <title>Device Node Creation</title> -->
    91 
    92       <para>When Udev was introduced, the <command>udevd</command> daemon made
    93       calls to mknod() to create device nodes in
    94       <filename class="directory">/dev</filename> dynamically, based on the
     91      <para>Shortly after the introduction of
     92      <systemitem class="filesystem">sysfs</systemitem>, work began on a
     93      program called Udev to advantage of it. The <command>udev</command>
     94      daemon made calls to <function>mknod()</function> to create device nodes
     95      in <filename class="directory">/dev</filename> dynamically, based on the
    9596      information from <systemitem class="filesystem">sysfs</systemitem>, in
    9697      <filename class="directory">/sys</filename>. For example,
    9798      <filename>/sys/class/tty/vcs/dev</filename> contains the string
    98       <quote>7:0</quote>. This string was used by <command>udevd</command>
     99      <quote>7:0</quote>. This string was used by <command>udev</command>
    99100      to create a device node with major number <emphasis>7</emphasis> and
    100       minor number <emphasis>0</emphasis>. Using the Udev method
    101       only those devices which are detected by the kernel would get device
    102       nodes created for them. Because these device nodes were created each time
    103       the system boots, they were stored on a
    104       <systemitem class="filesystem">tmpfs</systemitem> file system (a virtual
    105       file system that resides entirely in system memory). Device nodes do not
    106       require much space, so the memory that is used is negligible.</para>
     101      minor number <emphasis>0</emphasis>.</para>
    107102
    108103      <para>Linux kernel version 2.6.32 introduced a new virtual file system
    109       called <systemitem class="filesystem">devtmpfs</systemitem>, a
    110       replacement for <systemitem class="filesystem">devfs</systemitem>.
    111       With this approach, a
    112       <systemitem class="filesystem">devtmpfs</systemitem> file system is
    113       mounted on <filename class="directory">/dev/</filename> when the system
    114       is booted, and all needed device nodes are created on this virtual
    115       file system. As of version 176, Udev no longer creates device nodes
    116       itself, instead relying on
     104      called <systemitem class="filesystem">devtmpfs</systemitem>, an improved
     105      replacement for <systemitem class="filesystem">devfs</systemitem>. This
     106      allows device nodes to once again be dynamically created by the kernel,
     107      without many of the problems of
     108      <systemitem class="filesystem">devfs</systemitem>. As of version 176,
     109      Udev no longer creates device nodes itself, instead relying on
    117110      <systemitem class="filesystem">devtmpfs</systemitem> to do so.</para>
    118111
    119       <para>Udev also sets appropriate ownership and permissions
    120       for the device nodes, and creates extra symlinks as needed (such as
    121       <filename class="symlink">/dev/cdrom</filename>). The ownership and
    122       permissions of the nodes under the
    123       <filename class="directory">/dev</filename> directory are
    124       determined by rules specified in the files within the <filename
    125       class="directory">/etc/udev/rules.d/</filename> directory. These are
    126       numbered in a similar fashion to the CLFS-Bootscripts package. If
    127       <command>udevd</command> can't find a rule for the device it is creating,
    128       it will default permissions to <emphasis>660</emphasis> and ownership to
    129       <emphasis>root:root</emphasis>.</para>
    130 
    131112    </sect3>
    132113
     
    134115      <title>Systemd and Eudev</title>
    135116
    136         <para>In May 2012, Udev's source was merged with systemd, an alternate
    137         <command>init</command> implementation. Some time later, several Gentoo
    138         developers took the Udev code from systemd and created a fork called
    139         Eudev.</para>
    140 
    141     </sect3>
     117        <para>In 2010, development began on systemd, an alternate
     118        <command>init</command> implementation. Starting with Udev 183, Udev's
     119        source tree was merged with systemd. Several Gentoo
     120        developers who disagreed with this merge announced a project fork
     121        called Eudev in December 2012, created by extracting the
     122        Udev code from systemd. One of the goals of Eudev is to allow for
     123        easier installation and usage of <command>udevd</command> without
     124        the need for the rest of systemd.</para>
     125    </sect3>
     126
     127  </sect2>
     128
     129  <sect2>
     130    <title>Device Node Creation</title>
     131
     132    <para>By default, device nodes created by the kernel in a
     133    <systemitem class="filesystem">devtmpfs</systemitem> are owned by
     134    <emphasis>root:root</emphasis> and have <emphasis>600</emphasis>
     135    permissions. <command>udevd</command> can modify ownership and permissions
     136    of the nodes under the <filename class="directory">/dev</filename>
     137    directory, and can also create additional symlinks, based on rules
     138    specified in the files within the
     139    <filename class="directory">/etc/udev/rules.d</filename>,
     140    <filename class="directory">/lib/udev/rules.d</filename>,
     141    and <filename class="directory">/run/udev/rules.d</filename> directories.
     142    The names for these files start with a number, to indicate the order in
     143    which they are run, and they have a <filename>.rules</filename>
     144    extension (<command>udevd</command> will ignore files with any other
     145    extension). All of the rules files from these directories are combined into
     146    a single list, sorted by filename, and run in that order. In the event of
     147    a conflict, where a rules file with the same name exists in two or more of
     148    these directories, the rules in <filename class="directory">/etc</filename>
     149    take the highest priority, followed by rules files in
     150    <filename class="directory">/run</filename>, and finally
     151    <filename class="directory">/lib</filename>. Any device for which a rule
     152    cannot be found will just be ignored by <command>udevd</command>
     153    and be left at the defaults defined by the kernel, as described above. For
     154    more details about writing Udev rules, see
     155    <ulink url="/usr/share/doc/systemd-&systemd-version;/udev.html" />.</para>
    142156
    143157  </sect2>
     
    177191
    178192  <sect2>
    179     <title>Handling Hotpluggable/Dynamic Devices</title>
    180 
    181     <para>When you plug in a device, such as a Universal Serial Bus (USB) MP3
    182     player, the kernel recognizes that the device is now connected and
    183     generates a uevent. This uevent is then handled by
    184     <command>udevd</command> as described above.</para>
    185 
    186   </sect2>
    187 
    188   <sect2>
    189193    <title>Problems with Loading Modules and Creating Devices</title>
    190194
     
    235239      sound cards available to OSS applications), configure
    236240      <command>modprobe</command> to load the wrapper after Udev loads the
    237       wrapped module. To do this, add an <quote>install</quote> line in
    238       <filename>/etc/modprobe.conf</filename>. For example:</para>
     241      wrapped module. To do this, add an <quote>install</quote> line to a file
     242      in <filename>/etc/modprobe.d</filename>. For example:</para>
    239243
    240244<screen role="nodump"><literal>install snd-pcm /sbin/modprobe -i snd-pcm ; \
     
    253257
    254258      <para>Either don't build the module, or blacklist it in
    255       <filename>/etc/modprobe.conf</filename> file as done with the
     259      <filename>/etc/modprobe.d</filename> file as done with the
    256260      <emphasis>forte</emphasis> module in the example below:</para>
    257261
     
    264268
    265269    <sect3>
    266       <title>Udev creates a device incorrectly, or makes a wrong symlink</title>
     270      <title>Udev makes a wrong symlink</title>
    267271
    268272      <para>This usually happens if a rule unexpectedly matches a device. For
Note: See TracChangeset for help on using the changeset viewer.