| 1 | <?xml version='1.0' encoding="UTF-8"?> |
1 | <?xml version='1.0' encoding="UTF-8"?> |
| 2 | <!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> |
2 | <!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> |
| 3 | <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/udev-guide.xml,v 1.52 2010/12/26 19:21:44 nightmorph Exp $ --> |
3 | <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/udev-guide.xml,v 1.53 2011/03/12 05:44:14 nightmorph Exp $ --> |
| 4 | |
4 | |
| 5 | <guide> |
5 | <guide> |
| 6 | <title>Gentoo udev Guide</title> |
6 | <title>Gentoo udev Guide</title> |
| 7 | |
7 | |
| 8 | <author title="Author"> |
8 | <author title="Author"> |
| … | |
… | |
| 21 | |
21 | |
| 22 | <!-- The content of this document is licensed under the CC-BY-SA license --> |
22 | <!-- The content of this document is licensed under the CC-BY-SA license --> |
| 23 | <!-- See http://creativecommons.org/licenses/by-sa/2.5 --> |
23 | <!-- See http://creativecommons.org/licenses/by-sa/2.5 --> |
| 24 | <license/> |
24 | <license/> |
| 25 | |
25 | |
| 26 | <version>7</version> |
26 | <version>8</version> |
| 27 | <date>2010-12-26</date> |
27 | <date>2011-03-11</date> |
| 28 | |
28 | |
| 29 | <chapter> |
29 | <chapter> |
| 30 | <title>What is udev?</title> |
30 | <title>What is udev?</title> |
| 31 | <section> |
31 | <section> |
| 32 | <title>The /dev Directory</title> |
32 | <title>The /dev Directory</title> |
| … | |
… | |
| 69 | <li>Provides consistent naming</li> |
69 | <li>Provides consistent naming</li> |
| 70 | <li>Provides a user-space API</li> |
70 | <li>Provides a user-space API</li> |
| 71 | </ul> |
71 | </ul> |
| 72 | |
72 | |
| 73 | <p> |
73 | <p> |
| 74 | To provide these features, udev is developed in three separate projects: |
74 | Every time a change happens within the device structure, the kernel emits a |
| 75 | <e>namedev</e>, <e>libsysfs</e> and, of course, <e>udev</e>. |
75 | <e>uevent</e> which gets picked up by udev. udev then follows the rules as |
| 76 | </p> |
76 | declared in the <path>/etc/udev/rules.d</path> and |
| 77 | |
77 | <path>/lib/udev/rules.d</path> directories. Based on the information contained |
| 78 | </body> |
78 | within the uevent, it finds the rule or rules it needs to trigger and performs |
| 79 | </section> |
79 | the required actions. These actions can be creating or deleting device files, |
| 80 | <section> |
80 | but can also trigger the loading of particular firmware files into the |
| 81 | <title>namedev</title> |
81 | kernel memory. |
| 82 | <body> |
|
|
| 83 | |
|
|
| 84 | <p> |
|
|
| 85 | Namedev allows you to define the device naming separately from the udev program. |
|
|
| 86 | This allows for flexible naming policies and naming schemes developed by |
|
|
| 87 | separate entities. This device naming subsystem provides a standard interface |
|
|
| 88 | that udev can use. |
|
|
| 89 | </p> |
|
|
| 90 | |
|
|
| 91 | <p> |
|
|
| 92 | Currently only a single naming scheme is provided by namedev; the one provided |
|
|
| 93 | by LANANA, used by the majority of Linux systems currently and therefore very |
|
|
| 94 | suitable for the majority of Linux users. |
|
|
| 95 | </p> |
|
|
| 96 | |
|
|
| 97 | <p> |
|
|
| 98 | Namedev uses a 5-step procedure to find out the name of a given device. If the |
|
|
| 99 | device name is found in one of the given steps, that name is used. The steps |
|
|
| 100 | are: |
|
|
| 101 | </p> |
|
|
| 102 | |
|
|
| 103 | <ul> |
|
|
| 104 | <li>label or serial number</li> |
|
|
| 105 | <li>bus device number</li> |
|
|
| 106 | <li>bus topology</li> |
|
|
| 107 | <li>statically given name</li> |
|
|
| 108 | <li>kernel provided name</li> |
|
|
| 109 | </ul> |
|
|
| 110 | |
|
|
| 111 | <p> |
|
|
| 112 | The <e>label or serial number</e> step checks if the device has a unique |
|
|
| 113 | identifier. For instance USB devices have a unique USB serial number; SCSI |
|
|
| 114 | devices have a unique UUID. If namedev finds a match between this unique number |
|
|
| 115 | and a given configuration file, the name provided in the configuration file is |
|
|
| 116 | used. |
|
|
| 117 | </p> |
|
|
| 118 | |
|
|
| 119 | <p> |
|
|
| 120 | The <e>bus device number</e> step checks the device bus number. For |
|
|
| 121 | non-hot-swappable environments this procedure is sufficient to |
|
|
| 122 | identify a hardware device. For instance PCI bus numbers rarely change in the |
|
|
| 123 | lifetime of a system. Again, if namedev finds a match between this position and |
|
|
| 124 | a given configuration file, the name provided in that configuration file is |
|
|
| 125 | used. |
|
|
| 126 | </p> |
|
|
| 127 | |
|
|
| 128 | <p> |
|
|
| 129 | Likewise the <e>bus topology</e> is a rather static way of defining devices as |
|
|
| 130 | long as the user doesn't switch devices. When the position of the device matches |
|
|
| 131 | a given setting provided by the user, the accompanying name is used. |
|
|
| 132 | </p> |
|
|
| 133 | |
|
|
| 134 | <p> |
|
|
| 135 | The fourth step, <e>statically given name</e>, is a simple string replacement. |
|
|
| 136 | When the kernel name (the default name) matches a given replacement string, the |
|
|
| 137 | substitute name will be used. |
|
|
| 138 | </p> |
|
|
| 139 | |
|
|
| 140 | <p> |
|
|
| 141 | The final step (<e>kernel provided name</e>) is a catch-all: this one takes |
|
|
| 142 | the default name provided by the kernel. In the majority of cases this is |
|
|
| 143 | sufficient as it matches the device naming used on current Linux systems. |
|
|
| 144 | </p> |
|
|
| 145 | |
|
|
| 146 | </body> |
|
|
| 147 | </section> |
|
|
| 148 | <section> |
|
|
| 149 | <title>libsysfs</title> |
|
|
| 150 | <body> |
|
|
| 151 | |
|
|
| 152 | <p> |
|
|
| 153 | udev interacts with the kernel through the sysfs pseudo filesystem. The libsysfs |
|
|
| 154 | project provides a common API to access the information given by the sysfs |
|
|
| 155 | filesystem in a generic way. This allows for querying all kinds of hardware |
|
|
| 156 | without having to make assumptions on the kind of hardware. |
|
|
| 157 | </p> |
|
|
| 158 | |
|
|
| 159 | </body> |
|
|
| 160 | </section> |
|
|
| 161 | <section> |
|
|
| 162 | <title>udev</title> |
|
|
| 163 | <body> |
|
|
| 164 | |
|
|
| 165 | <p> |
|
|
| 166 | Every time the kernel gets an event in the device structure, it asks udev to |
|
|
| 167 | take a look. udev follows the rules in the <path>/etc/udev/rules.d/</path> |
|
|
| 168 | directory. udev then uses the information given by the kernel to perform the |
|
|
| 169 | necessary actions on the <path>/dev</path> structure (creating or deleting |
|
|
| 170 | device files). |
|
|
| 171 | </p> |
82 | </p> |
| 172 | |
83 | |
| 173 | </body> |
84 | </body> |
| 174 | </section> |
85 | </section> |
| 175 | </chapter> |
86 | </chapter> |
| … | |
… | |
| 180 | <title>Requirements</title> |
91 | <title>Requirements</title> |
| 181 | <body> |
92 | <body> |
| 182 | |
93 | |
| 183 | <p> |
94 | <p> |
| 184 | udev is meant to be used in combination with a 2.6 kernel (like |
95 | udev is meant to be used in combination with a 2.6 kernel (like |
| 185 | <c>gentoo-sources</c> with the default 2007.0 profile). If you're using such a |
96 | <c>gentoo-sources</c> with the default 10.0 profile). If you're using such a |
| 186 | kernel then you just have to make sure that you have a recent |
97 | kernel then you just should have no issues whatsoever with using udev as the |
| 187 | <c>sys-apps/baselayout</c> version. That's all you need. |
98 | necessary support is built-in in all stable <c>sys-apps/baselayout</c> |
|
|
99 | versions. Normally, udev should already be installed on your system, but if |
|
|
100 | this is not the case, then it is easy to install: |
| 188 | </p> |
101 | </p> |
| 189 | |
102 | |
| 190 | <pre caption="Installing udev"> |
103 | <pre caption="Installing udev"> |
| 191 | # <i>emerge udev</i> |
104 | # <i>emerge udev</i> |
| 192 | </pre> |
105 | </pre> |
| … | |
… | |
| 194 | <p> |
107 | <p> |
| 195 | Kernelwise, be sure to activate the following options: |
108 | Kernelwise, be sure to activate the following options: |
| 196 | </p> |
109 | </p> |
| 197 | |
110 | |
| 198 | <pre caption="Required kernel options"> |
111 | <pre caption="Required kernel options"> |
|
|
112 | General Setup ---> |
|
|
113 | <comment>(Make sure the following item is *not* enabled)</comment> |
|
|
114 | [ ] enable deprecated sysfs features to support old userspace tools |
|
|
115 | |
| 199 | File systems ---> |
116 | File Systems ---> |
| 200 | [*] Inotify file change notification support |
|
|
| 201 | [*] Inotify support for userspace |
117 | [*] Inotify support for userspace |
| 202 | Pseudo filesystems ---> |
118 | Pseudo filesystems ---> |
| 203 | [*] /proc file system support |
|
|
| 204 | [*] Virtual memory file system support (former shm fs) |
119 | [*] Virtual memory file system support (former shm fs) |
| 205 | </pre> |
120 | </pre> |
| 206 | |
121 | |
| 207 | <p> |
122 | <p> |
| 208 | If you use <c>genkernel</c>, you don't need to do anything special. Genkernel |
123 | If you use <c>genkernel</c>, you don't need to do anything special. Genkernel |
| 209 | sets up udev by default. |
124 | sets up udev by default. |
| 210 | </p> |
|
|
| 211 | |
|
|
| 212 | </body> |
|
|
| 213 | </section> |
|
|
| 214 | <section> |
|
|
| 215 | <title>Configuration</title> |
|
|
| 216 | <body> |
|
|
| 217 | |
|
|
| 218 | <p> |
|
|
| 219 | If you want to use the udev settings Gentoo provides to make your life |
|
|
| 220 | comfortable, then read no more. Gentoo will use udev but keep a static |
|
|
| 221 | <path>/dev</path> so that you will never have any missing device nodes. |
|
|
| 222 | The Gentoo init scripts won't run the devfsd daemon and will deactivate devfs |
|
|
| 223 | when you boot up. |
|
|
| 224 | </p> |
|
|
| 225 | |
|
|
| 226 | <p> |
|
|
| 227 | But if you are a die-hard and want to run a udev-only, unmodified system as is |
|
|
| 228 | intended by the udev development (including the difficulties of missing device |
|
|
| 229 | nodes because udev doesn't support them yet), by all means, read on :) |
|
|
| 230 | </p> |
|
|
| 231 | |
|
|
| 232 | <p> |
|
|
| 233 | We'll deactivate the rules that save the device file nodes: edit the |
|
|
| 234 | <c>RC_DEVICE_TARBALL</c> variable in <path>/etc/conf.d/rc</path> and set it to |
|
|
| 235 | <c>no</c>: |
|
|
| 236 | </p> |
|
|
| 237 | |
|
|
| 238 | <pre caption="/etc/conf.d/rc"> |
|
|
| 239 | RC_DEVICE_TARBALL="no" |
|
|
| 240 | </pre> |
|
|
| 241 | |
|
|
| 242 | <p> |
|
|
| 243 | If you have included devfs support in your kernel, you can deactivate it in |
|
|
| 244 | the bootloader configuration: add <c>gentoo=nodevfs</c> as a kernel parameter. |
|
|
| 245 | If you want to use devfs and deactivate udev, add <c>gentoo=noudev</c> as kernel |
|
|
| 246 | parameter. |
|
|
| 247 | </p> |
125 | </p> |
| 248 | |
126 | |
| 249 | </body> |
127 | </body> |
| 250 | </section> |
128 | </section> |
| 251 | </chapter> |
129 | </chapter> |