/[gentoo]/xml/htdocs/doc/en/udev-guide.xml
Gentoo

Contents of /xml/htdocs/doc/en/udev-guide.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download) (as text)
Mon Mar 15 10:40:02 2004 UTC (14 years, 4 months ago) by neysx
Branch: MAIN
Changes since 1.4: +2 -2 lines
File MIME type: application/xml
Rephrased wrongfully fixed sentence

1 <?xml version='1.0' encoding="UTF-8"?>
2 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
3
4 <!-- $Header: /home/cvsroot/gentoo/xml/htdocs/doc/en/udev-guide.xml,v 1.4 2004/03/15 00:31:04 neysx Exp $ -->
5
6 <guide link="/doc/en/udev-guide.xml">
7 <title>Gentoo udev Guide</title>
8
9 <author title="Author">
10 <mail link="swift@gentoo.org">Sven Vermeulen</mail>
11 </author>
12
13 <abstract>
14 This document explains what udev is and how you can use udev to fit your needs.
15 </abstract>
16
17 <license/>
18
19 <version>0.4</version>
20 <date>March 15, 2004</date>
21
22 <chapter>
23 <title>What is udev?</title>
24 <section>
25 <title>The /dev Directory</title>
26 <body>
27
28 <p>
29 When Linux-users talk about the hardware on their system in the vicinity of
30 people who believe Linux is some sort of virus or brand of coffee, the use of
31 "slash dev slash foo" will return a strange look for sure. But for the fortunate
32 user (and that includes you) using <path>/dev/hda1</path> is just a fast way of
33 explaining that we are talking about the primary master IDE, first partition. Or
34 aren't we?
35 </p>
36
37 <p>
38 We all know what a device file is. Some even know why device files have special
39 numbers when we take a closer look at them when we issue <c>ls -l</c> in
40 <path>/dev</path>. But what we always take for granted is that the primary
41 master IDE disk is referred to as <path>/dev/hda</path>. You might not see it
42 this way, but this is a flaw by design.
43 </p>
44
45 <p>
46 Think about hotpluggable devices like USB, IEEE1394, hot-swappable PCI, ... What
47 is the first device? And for how long? What will the other devices be named when
48 the first one disappears? How will that affect ongoing transactions? Wouldn't it
49 be fun that a printing job is suddenly moved from your supernew laserprinter to
50 your almost-dead matrix printer because your mom decided to pull the plug of the
51 inkjet which happened to be the first printer?
52 </p>
53
54 <p>
55 Enter <e>udev</e>. The goals of the udev project are both interesting and
56 needed:
57 </p>
58
59 <ul>
60 <li>Runs in userspace</li>
61 <li>Dynamically creates/removes device files</li>
62 <li>Provides consistent naming</li>
63 <li>Provides a user-space API</li>
64 </ul>
65
66 <p>
67 To provide these features, udev is developed in three separate projects:
68 <e>namedev</e>, <e>libsysfs</e> and, of course, <e>udev</e>.
69 </p>
70
71 </body>
72 </section>
73 <section>
74 <title>namedev</title>
75 <body>
76
77 <p>
78 Namedev allows you to define the device naming separately from the udev program.
79 This allows for flexible naming policies and naming schemes developed by
80 separate entities. This device naming subsystem provides a standard interface
81 that udev can use.
82 </p>
83
84 <p>
85 Currently only a single naming scheme is provided by namedev; the one provided
86 by LANANA, used by the majority of Linux systems currently and therefore very
87 suitable for the majority of Linux users.
88 </p>
89
90 <p>
91 Namedev uses a 5-step procedure to find out the name of a given device. If the
92 device name is found in one of the given steps, that name is used. The steps
93 are:
94 </p>
95
96 <ul>
97 <li>label or serial number</li>
98 <li>bus device number</li>
99 <li>bus topology</li>
100 <li>statically given name</li>
101 <li>kernel provided name</li>
102 </ul>
103
104 <p>
105 The <e>label or serial number</e> step checks if the device has a unique
106 identifier. For instance USB devices have a unique USB serial number; SCSI
107 devices have a unique UUID. If namedev finds a match between this unique number
108 and a given configuration file, the name provided in the configuration file is
109 used.
110 </p>
111
112 <p>
113 The <e>bus device number</e> step checks the device bus number. For
114 non-hot-swappable environments this procedure is sufficient to
115 identify a hardware device. For instance PCI bus numbers rarely change in the
116 lifetime of a system. Again, if namedev finds a match between this position and
117 a given configuration file, the name provided in that configuration file is
118 used.
119 </p>
120
121 <p>
122 Likewise the <e>bus topology</e> is a rather static way of defining devices as
123 long as the user doesn't switch devices. When the position of the device matches
124 a given setting provided by the user, the accompanying name is used.
125 </p>
126
127 <p>
128 The fourth step, <e>statically given name</e>, is a simple string replacement.
129 When the kernel name (the default name) matches a given replacement string, the
130 substitute name will be used.
131 </p>
132
133 <p>
134 The final step (<e>kernel provided name</e>) is a catch-all: this one takes
135 the default name provided by the kernel. In the majority of cases this is
136 sufficient as it matches the device naming used on current Linux systems.
137 </p>
138
139 </body>
140 </section>
141 <section>
142 <title>libsysfs</title>
143 <body>
144
145 <p>
146 udev interacts with the kernel through the sysfs pseudo filesystem. The libsysfs
147 project provides a common API to access the information given by the sysfs
148 filesystem in a generic way. This allows for querying all kinds of hardware
149 without having to make assumptions on the kind of hardware.
150 </p>
151
152 </body>
153 </section>
154 <section>
155 <title>udev</title>
156 <body>
157
158 <p>
159 Every time the kernel notices an update in the device structure, it calls the
160 <path>/sbin/hotplug</path> program. Hotplug runs the applications linked in the
161 <path>/etc/hotplug.d/default</path> directory where you will also find a symlink
162 to the udev application. Hotplug directs the information given by the kernel to
163 the udev application which performs the necessary actions on the
164 <path>/dev</path> structure (creating or deleting device files).
165 </p>
166
167 </body>
168 </section>
169 </chapter>
170
171 <chapter>
172 <title>Using udev on Gentoo</title>
173 <section>
174 <title>Requirements</title>
175 <body>
176
177 <p>
178 To be able to use udev on Gentoo, you must install
179 <c>sys-apps/baselayout-1.8.6.13-r1</c> or later and <c>sys-fs/udev</c>.
180 If necessary, edit <path>/etc/portage/package.keywords</path> so that your
181 system uses the ~ARCH tree for <c>sys-fs/udev</c>:
182 </p>
183
184 <pre caption="/etc/portage/package.keywords">
185 sys-fs/udev ~x86
186 </pre>
187
188 <p>
189 If you haven't done so already, also install <c>sys-apps/hotplug</c>.
190 </p>
191
192 <pre caption="Installing necessary tools">
193 # <i>emerge baselayout udev hotplug</i>
194 </pre>
195
196 <p>
197 Kernelwise, if you're using the default set by <c>genkernel</c> then you're all
198 set. Otherwise be sure to activate the following options:
199 </p>
200
201 <pre caption="Required kernel options">
202 Bus options (PCI, PCMCIA, EISA, MCA, ISA) ---&gt;
203 [*] Support for hot-pluggable devices
204
205 File systems ---&gt;
206 Pseudo filesystems ---&gt;
207 [*] /proc file system support
208 [*] /dev/pts file system for Unix98 PTYs
209 [*] Virtual memory file system support (former shm fs)
210 </pre>
211
212 <p>
213 You can leave the <c>/dev file system support (OBSOLETE)</c> active if you
214 wish.
215 </p>
216
217 </body>
218 </section>
219 <section>
220 <title>Configuration</title>
221 <body>
222
223 <p>
224 If you want to use the udev-tweaks Gentoo added to make your life
225 comfortable, then read no more. You're all set. The Gentoo init scripts won't
226 run the devfsd daemon and will deactivate devfs when you boot up.
227 </p>
228
229 <p>
230 But if you are a die-hard and want to run a udev-only, no-tweaked system as is
231 intended by the udev development (including the difficulties of missing device
232 nodes because udev doesn't support them yet), by all means, read on :)
233 </p>
234
235 <warn>
236 Do <e>not</e> complain if something goes wrong. You're going to remove the hard
237 work of many Gentoo developers that hacked our init scripts to get udev playing
238 nicely with Gentoo!
239 </warn>
240
241 <p>
242 First of all we'll deactivate the rules that save the device file nodes.
243 From <c>sys-apps/baselayout-1.8.6.13-r1</c> onwards, you can edit the
244 <c>RC_DEVICE_TARBALL</c> variable in <path>/etc/conf.d/rc</path> and set it to
245 <c>no</c>:
246 </p>
247
248 <pre caption="/etc/conf.d/rc">
249 RC_DEVICE_TARBALL="no"
250 </pre>
251
252 <p>
253 We also need to manually create some device node files in order for our system
254 to perform a succesful boot:
255 </p>
256
257 <pre caption="Creating necessary device node files">
258 # <i>mknod -m 660 /dev/console c 5 1</i>
259 # <i>mknod -m 660 /dev/null c 1 3</i>
260 </pre>
261
262 <p>
263 If you have included devfs support in your kernel, you can deactivate it from
264 the bootloader configuration: add <c>devfs=nomount</c> as kernel parameter.
265 </p>
266
267 <p>
268 If you want to use devfs and deactivate udev, add <c>gentoo=noudev</c> as kernel
269 parameter.
270 </p>
271
272 </body>
273 </section>
274 <section>
275 <title>Current Issues</title>
276 <body>
277
278 <p>
279 Please report the <e>temporary fixes</e> to current issues to the Gentoo
280 Documentation Project by using the <uri link="http://bugs.gentoo.org">Gentoo
281 Bugzilla</uri> website.
282 </p>
283
284 </body>
285 </section>
286 </chapter>
287
288 <chapter>
289 <title>Resources &amp; Acknowledgements</title>
290 <section>
291 <body>
292
293 <p>
294 The udev talk on the Linux Symposium (Ottawa, Ontario Canada - 2003) given by
295 Greg Kroah-Hartman (IBM Corporation) provided a solid understanding on the udev
296 application.
297 </p>
298
299 <p>
300 <uri link="http://webpages.charter.net/decibelshelp/LinuxHelp_UDEVPrimer.html">Decibel's
301 UDEV Primer</uri> is an in-depth document about udev and Gentoo.
302 </p>
303
304 </body>
305 </section>
306 </chapter>
307
308 </guide>

  ViewVC Help
Powered by ViewVC 1.1.20