chiark / gitweb /
all man pages rewritten to use DocBook XML
[elogind.git] / docs / fedora_udev.html
1
2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4         <head>
5                 <title>Fedora Project, sponsored by Red Hat</title>
6                 <base href="http://fedora.redhat.com/">
7                 <meta http-equiv="Content-Type" content="text/html">
8                 <link rel="stylesheet" type="text/css" media="print" href="/css/print.css">
9                 <style type="text/css" media="screen">
10                         @import url("/css/layout.css");
11                         @import url("/css/content.css");
12                         @import url("/css/docbook.css");
13                 </style>
14                 <meta name="MSSmartTagsPreventParsing" content="TRUE">
15                 <link rel="shortcut icon" href="/images/favicon.ico">
16                 <link rel="icon" href="/images/favicon.ico">
17         </head>
18
19         <body>
20                 <!-- header BEGIN -->
21                 <div id="fedora-header">
22                         <div id="fedora-header-logo">
23                                 <a href="/"><img src="/images/header-fedora_logo.png" alt="Fedora Project"></a>
24                         </div>
25
26                         <div id="fedora-header-items">
27                                 <span class="fedora-header-icon">
28                                         <a href="/download/"><img src="/images/header-download.png" alt=" ">Download</a>
29                                         <a href="/projects/"><img src="/images/header-projects.png" alt=" ">Projects</a>
30                                         <a href="/about/faq/"><img src="/images/header-faq.png" alt=" ">FAQ</a></span>
31                         </div>
32                 </div>
33
34                 <div id="fedora-nav"></div>
35                 <!-- header END -->
36                 
37                 <!-- leftside BEGIN -->
38                 <div id="fedora-side-left">
39                 <div id="fedora-side-nav-label">Site Navigation:</div>  <ul id="fedora-side-nav">
40                                 <li><a href="/">Home</a></li>
41                                 <li><a href="/download/">Download</a></li>
42                                 <li><a href="/docs/">Docs</a></li>
43                                 <li><a href="/projects/">Projects</a></li>
44                                 <li><a href="/participate/">Participate</a></li>
45                                 <li><a href="/about/">About</a></li>
46                         </ul>
47                 </div>
48
49                 <!-- leftside END -->
50
51                 <!-- content BEGIN -->
52                 <div id="fedora-middle-two">
53                         <div class="fedora-corner-tr">&nbsp;</div>
54                         <div class="fedora-corner-tl">&nbsp;</div>
55                         <div id="fedora-content">
56                                                 <!-- content BEGIN -->
57                 <h1>Udev on Fedora</h1>
58                 <h2>by Harald Hoyer</h2>
59                 <p>
60                 This document tries to reveal the secrets of udev and how it works on Fedora.
61                 </p>
62                 <p>
63                 udev was developed by Greg  Kroah-Hartman  &lt;greg@kroah.com&gt;  with  much
64                 help  from  Dan  Stekloff &lt;dsteklof@us.ibm.com&gt;, Kay Sievers &lt;kay.sievers@vrfy.org&gt;,
65                  and many others.
66                 </p>
67                 <p>
68                 The <a href="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html">udev homepage</a> and the
69                 Linux-hotplug-devel mailing list  <a href="https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel">https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel</a> are the main development sources.             
70                 </p><p>
71                 </p>
72
73                 <h2>What Does Udev Do?</h2>
74                 <p>
75                 udev  provides a dynamic device directory containing only the files for
76                 actually present devices. It creates or removes device node files  usually
77                 located in the <tt class="filename">/dev/</tt> directory, or it renames network interfaces.
78                 </p><p>
79                 As  part  of the hotplug subsystem, udev is executed if a kernel device
80                 is added or removed from the system.  On device  creation,  udev  reads
81                 the  sysfs  directory  of the given device to collect device attributes
82                 like label, serial number or bus device number.  These  attributes  may
83                 be  used as keys to determine a unique name for the device.  udev maintains
84                 a database for devices present on the system.
85                 On device removal, udev queries its database for the name of the device
86                 file to be deleted.
87                 </p><p>
88                 udev gets called by hotplug, if a module is loaded, and a device is added
89                 or removed. udev looks in <tt class="filename">/sys/</tt>, if the driver provides a "dev" file, which 
90                 contains the major and minor number for a device node to communicate with 
91                 the driver. After looking in the udev rules (in the <tt class="filename">/etc/udev/rules.d/</tt> directory), which 
92                 specify the device node filename and symlinks, a device node is created 
93                 in <tt class="filename">/dev/</tt> with the permissions, which are specified in <tt class="filename">/etc/udev/permissions.d/</tt>.
94                 </p>
95                 After device node creation, removal, or network device  renaming,  udev
96                 executes  the  programs  in  the directory tree under <tt class="filename">/etc/dev.d/</tt>.  The
97                 name of a program must end with the <tt class="filename">.dev</tt> suffix, to be recognized.
98                 In addition to the hotplug environment variables, DEVNAME  is  exported
99                 to make the name of the created node or the name the network device is
100                 renamed to, available to the executed program. The  programs  in  every
101                 directory  are  sorted  in  lexical  order,  while  the directories are
102                 searched in the following order:
103                 <ul>
104                 <li><tt class="filename">/etc/dev.d/$(DEVNAME)/*.dev</tt></li>
105                 <li><tt class="filename">/etc/dev.d/$(SUBSYSTEM)/*.dev</tt></li>
106                 <li><tt class="filename">/etc/dev.d/default/*.dev</tt></li>
107                 </ul>
108                 
109                 <h2>How is Udev Integrated on Fedora?</h2>
110                 <h3><tt class="command">initrd</tt> / <tt class="command">initfs</tt></h3>
111                 <p>
112                 <tt class="command">mkinitrd</tt> copies <tt class="filename">/sbin/udev.static</tt> 
113                 to the <tt class="command">initrd</tt> <tt class="filename">/sbin/udev</tt> and symlinks it to 
114                 <tt class="filename">/sbin/udevstart</tt>.
115                 </p><p>
116 After the kernel boots, it executes the nash script of the <tt class="command">initrd</tt>. This
117 mounts a tmpfs filesystem on <tt class="filename">/dev/</tt>. Instead of hotplug <tt class="command">/sbin/udev</tt> is
118 called in the <tt class="command">initrd</tt> phase. udevstart creates all device nodes for the
119 devices, which are compiled in the kernel and for the modules, which
120 are loaded by nash. </p>
121
122 <h4>Problems</h4> 
123
124 The whole udev and hotplug infrastructure is
125 not available in <tt class="command">initrd</tt>. Thus no hotplug scripts, udev rules, and
126 permissions and no <tt class="filename">/etc/dev.d/</tt> scripts are executed for any hotplug
127 event, which is sent from the kernel. 
128
129 <h3><tt class="filename">rc.sysinit</tt></h3>
130                 <p> First, if SELinux is loaded and enabled,
131 the context of <tt class="filename">/dev/</tt> is set. <tt class="filename">rc.sysinit</tt> calls <tt class="filename">/sbin/start_udev</tt>.
132 <tt class="filename">start_udev</tt> mounts a tmpfs filesystem on <tt class="filename">/dev/</tt>, if there is none already
133 mounted. Then it creates some device nodes, which need module
134 autoloading, or where there is no kernel module. After that
135 <tt class="command">/sbin/udevstart</tt> is called again, which simulates the hotplug events in
136 the <tt class="command">initrd</tt> phase, to apply the whole udev rules and permissions. After
137 that <tt class="filename">rc.sysinit</tt> parses the ouput of <tt class="filename">/sbin/kmodule</tt> and loads every
138 module. This should provide device nodes for all hardware found on your
139 computer. </p>
140                 <h3>Console User Permissions</h3>
141                 <p>
142 <tt class="filename">/etc/dev.d/default/pam_console.dev</tt> is called whenever a device node is
143 created and calls <tt class="filename">/sbin/pam_console_setowner</tt> with the filename (and an
144 optional symlink) of the device node. This sets the permissions for
145 console users like specified in <tt class="filename">/etc/security/console.perms</tt>. </p>
146                 <h2>Customizing Udev on Fedora</h2>
147                 <p>
148                 Read the manpage of udev and udevinfo.
149                 Please try not to modify the files of RPM packages.
150                 </p>
151                 <h3>New Rules</h3>
152                 <p>
153 New rules should be placed in a file, which ends in <tt class="filename">.rules</tt> in
154 <tt class="filename">/etc/udev/rules.d/</tt>. Please do not use <tt class="filename">50-udev.rules</tt>. The supported and
155 preferred way is to create rules without the "NAME" tag and only
156 create "SYMLINK"s. </p><p>              
157                 A nice document describing how to write rules can be found on <a href="http://www.reactivated.net/udevrules.php">http://www.reactivated.net/udevrules.php</a>.          
158                 </p>
159
160 <h3>Permissions</h3>
161 New permissions should be placed in a file, which ends in
162 <tt class="filename">.permissions</tt> in <tt class="filename">/etc/udev/permissions.d/</tt>. Please do not use
163 <tt class="filename">50-udev.permissions</tt>. 
164
165 <h3>But I Really Want My Device Node!</h3>
166                 <p>
167                 Put them in <tt class="filename">/etc/udev/devices/</tt>, and they will get copied to <tt class="filename">/dev/</tt>. <a href="https://bugzilla.redhat.com/bugzilla">File a bugzilla entry</a>, if you think that should be done per default.
168                 </p>
169
170                 <h2>Updating to udev Without <tt class="filename">/dev/</tt></h2>
171                 <p>
172                 The steps to upgrade without Anaconda or a rescue CD are (NOT recommended):
173                 </p>
174
175                 <ul>
176                 <li>start from a kernel-2.6
177                 </li><li>Make sure <tt class="filename">/sys/</tt> is mounted
178                 </li><li>Install the latest <tt class="filename">initscripts</tt> package
179                 </li><li>Install the latest <tt class="filename">udev</tt> package
180                 </li><li>Execute <tt class="command">/sbin/start_udev</tt>
181                 </li><li>Install the latest <tt class="filename">mkinitrd</tt> package
182                 </li><li>Install the latest <tt class="filename">kernel</tt> package
183                 </li><li>Or execute <tt class="command">mkinitrd</tt> for your existing kernel(s)
184                 </li></ul>
185                 
186                 <h2>Udev without <tt class="command">initrd</tt></h2>
187
188                 <p>Install Fedore Core as usual and reboot. Execute the following commands
189                 </p>
190
191 <pre class="screen">
192 <tt class="command">
193 mkdir /tmp/dev
194 mount --move /dev /tmp/dev
195 sbin/MAKEDEV null console zero
196 mount --move /tmp/dev /dev
197 </tt></pre>
198                 Install your kernel without an <tt class="command">initrd</tt>. Reboot.
199                 <p>
200                 You will get some SELinux errors, and syslogd will not work as expected.
201                 </p>
202                 <h2>Current Problems on Fedora</h2>     
203                 <p>
204                 <a href="http://bugzilla.redhat.com/bugzilla/buglist.cgi?short_desc_type=allwordssubstr&amp;component=udev&amp;bug_status=ASSIGNED&amp;bug_status=MODIFIED&amp;bug_status=NEEDINFO&amp;bug_status=NEW&amp;bug_status=REOPENED&amp;bug_status=VERIFIED&amp;bug_severity=high&amp;bug_severity=low&amp;bug_severity=normal&amp;bug_severity=security&amp;bug_severity=translation&amp;long_desc_type=allwordssubstr&amp;bug_file_loc_type=allwordssubstr&amp;status_whiteboard_type=allwordssubstr&amp;fixed_in_type=allwordssubstr&amp;devel_whiteboard_type=allwordssubstr&amp;keywords_type=allwords&amp;cust_facing=YES&amp;emailassigned_to1=1&amp;emailtype1=exact&amp;emailreporter2=1&amp;emailtype2=exact&amp;bugidtype=include&amp;chfieldto=Now&amp;cmdtype=doit&amp;remaction=run&amp;namedcmd=blank&amp;order=Reuse+same+sort+as+last+time&amp;field0-0-0=noop&amp;type0-0-0=noop">All open bugs for <code class="filename">udev</code></a>
205                 </p>
206                 <h3>Nvidia</h3>         
207                 <p>Quick solution: If you do not need rhgb, just load the nvidia module in <tt class="filename">/etc/rc.local</tt>
208                 </p><p>
209                 If you have udev &gt;= 032-5, load the nvidia module:
210                 </p>
211 <pre class="screen">
212 <tt class="command">
213 cp -a /dev/nvidia* /etc/udev/devices
214 chown root.root /etc/udev/devices/nvidia*
215 </tt></pre>
216                 
217                 <p>The Bugzilla for this problem is <strike><a href="https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=133900">133900</a></strike>.</p>
218                 <h3>Palm Pilot</h3>             
219                 <p>
220                 If you have udev &gt;= 032-5, execute the command:
221                 </p>
222 <pre class="screen">
223 <tt class="command">
224 ln -s ttyUSB1 /etc/udev/devices/pilot
225 </tt></pre>
226                 
227                 <h3>ISDN</h3>           
228                 <p>
229                 If you have udev &gt;= 032-5:
230                 </p>
231 <pre class="screen">
232 <tt class="command">
233 /sbin/MAKEDEV -d /etc/udev/devices isdn
234 </tt></pre>
235                 </pre>
236                 
237                 <!-- content END -->
238
239
240                 </div>
241                         <div class="fedora-corner-br">&nbsp;</div>
242                         <div class="fedora-corner-bl">&nbsp;</div>
243                 </div>
244                 <!-- content END -->
245                 
246                 <!-- footer BEGIN -->
247                 <div id="fedora-footer">
248                         Copyright &copy; 2003-2004 Red Hat, Inc. All rights reserved.
249                         <br>The Fedora Project is not a supported product of Red Hat, Inc.
250                         <br><a href="/legal/">Legal</a> | <a href="/about/trademarks/">Trademark Guidelines</a>
251                         <br>
252                         This page last modified at: 2004/10/16 02:25:17 
253                         <br>
254                 </div>
255                 <!-- footer END -->
256         </body>
257 </html>
258