1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
5 | %general-entities;
|
---|
6 | ]>
|
---|
7 |
|
---|
8 | <sect1 id="postlfs-devices" xreflabel="About Devices">
|
---|
9 | <?dbhtml filename="devices.html"?>
|
---|
10 |
|
---|
11 |
|
---|
12 | <title>About Devices</title>
|
---|
13 |
|
---|
14 | <indexterm zone="postlfs-devices">
|
---|
15 | <primary sortas="e-etc-udev-rules">/etc/udev/rules.d</primary>
|
---|
16 | </indexterm>
|
---|
17 |
|
---|
18 | <para>
|
---|
19 | Although most devices needed by packages in BLFS and beyond are set up
|
---|
20 | properly by <application>udev</application> using the default rules
|
---|
21 | installed by LFS in <filename
|
---|
22 | class="directory">/etc/udev/rules.d</filename>, there are cases where
|
---|
23 | the rules must be modified or augmented.
|
---|
24 | </para>
|
---|
25 |
|
---|
26 | <sect2>
|
---|
27 | <title>Multiple Sound Cards</title>
|
---|
28 |
|
---|
29 | <para>
|
---|
30 | If there are multiple sound cards in a system, the "default"
|
---|
31 | sound card becomes random. The method to establish sound card order
|
---|
32 | depends on whether the drivers are modules or not. If the sound card
|
---|
33 | drivers are compiled into the kernel, control is via kernel command line
|
---|
34 | parameters in <filename>/boot/grub/grub.cfg</filename>. For example,
|
---|
35 | if a system has both an FM801 card and a SoundBlaster PCI card, the
|
---|
36 | following can be appended to the command line:
|
---|
37 | </para>
|
---|
38 |
|
---|
39 | <screen><literal>snd-fm801.index=0 snd-ens1371.index=1</literal></screen>
|
---|
40 |
|
---|
41 | <para>
|
---|
42 | If the sound card drivers are built as modules, the order can be
|
---|
43 | established in the <filename>/etc/modprobe.conf</filename> file with:
|
---|
44 | </para>
|
---|
45 |
|
---|
46 | <screen><literal>options snd-fm801 index=0
|
---|
47 | options snd-ens1371 index=1</literal></screen>
|
---|
48 |
|
---|
49 | </sect2>
|
---|
50 |
|
---|
51 | <sect2 id="usb-device-issues">
|
---|
52 | <title>USB Device Issues</title>
|
---|
53 |
|
---|
54 | <para>
|
---|
55 | USB devices usually have two kinds of device nodes associated with them.
|
---|
56 | </para>
|
---|
57 |
|
---|
58 | <para>
|
---|
59 | The first kind is created by device-specific drivers (e.g.,
|
---|
60 | usb_storage/sd_mod or usblp) in the kernel. For example, a USB mass
|
---|
61 | storage device would be /dev/sdb, and a USB printer would be
|
---|
62 | /dev/usb/lp0. These device nodes exist only when the device-specific
|
---|
63 | driver is loaded.
|
---|
64 | </para>
|
---|
65 |
|
---|
66 | <para>
|
---|
67 | The second kind of device nodes (/dev/bus/usb/BBB/DDD, where BBB is
|
---|
68 | the bus number and DDD is the device number) are created even if the
|
---|
69 | device doesn't have a kernel driver. By using these "raw" USB device
|
---|
70 | nodes, an application can exchange arbitrary USB packets with the
|
---|
71 | device, i.e., bypass the possibly-existing kernel driver.
|
---|
72 | </para>
|
---|
73 |
|
---|
74 | <para>
|
---|
75 | Access to raw USB device nodes is needed when a userspace program is
|
---|
76 | acting as a device driver. However, for the program to open the device
|
---|
77 | successfully, the permissions have to be set correctly. By default, due
|
---|
78 | to security concerns, all raw USB devices are owned by user root and
|
---|
79 | group root, and have 0664 permissions (the read access is needed, e.g.,
|
---|
80 | for lsusb to work and for programs to access USB hubs). Packages (such
|
---|
81 | as SANE and libgphoto2) containing userspace USB device drivers also
|
---|
82 | ship udev rules that change the permissions of the controlled raw USB
|
---|
83 | devices. That is, rules installed by SANE change permissions for known
|
---|
84 | scanners, but not printers. If a package maintainer forgot to write
|
---|
85 | a rule for your device, report a bug to both BLFS (if the package is
|
---|
86 | there) and upstream, and you will need to write your own rule.
|
---|
87 | </para>
|
---|
88 |
|
---|
89 | <para>
|
---|
90 | Before Linux-2.6.15, raw USB device access was performed not with
|
---|
91 | /dev/bus/usb/BBB/DDD device nodes, but with /proc/bus/usb/BBB/DDD
|
---|
92 | pseudofiles. Some applications still use only
|
---|
93 | this deprecated technique and can't use the new device nodes. They
|
---|
94 | cannot work with Linux kernel version 3.5 or newer. If you need to
|
---|
95 | run such an application, contact the developer of it for a fix.
|
---|
96 | </para>
|
---|
97 |
|
---|
98 | </sect2>
|
---|
99 |
|
---|
100 | <sect2>
|
---|
101 | <title>Udev Device Attributes</title>
|
---|
102 |
|
---|
103 | <para>
|
---|
104 | Fine-tuning of device attributes such as group name and permissions
|
---|
105 | is possible by creating extra <application>udev</application> rules,
|
---|
106 | matching on something like this. The vendor and product can be found by
|
---|
107 | searching the <filename class='directory'>/sys/devices</filename>
|
---|
108 | directory entries or using <command>udevadm info</command> after the
|
---|
109 | device has been attached. See the documentation in the current
|
---|
110 | <application>udev</application> directory of <filename
|
---|
111 | class='directory'>/usr/share/doc</filename> for details.
|
---|
112 | </para>
|
---|
113 |
|
---|
114 | <screen><literal>SUBSYSTEM=="usb_device", SYSFS{idVendor}=="05d8", SYSFS{idProduct}=="4002", \
|
---|
115 | GROUP:="scanner", MODE:="0660"</literal></screen>
|
---|
116 |
|
---|
117 | <note>
|
---|
118 | <para>
|
---|
119 | The above line is used for descriptive purposes only. The
|
---|
120 | scanner <application>udev</application> rules are put into place when
|
---|
121 | installing <xref linkend='sane'/>.
|
---|
122 | </para>
|
---|
123 | </note>
|
---|
124 |
|
---|
125 | </sect2>
|
---|
126 |
|
---|
127 | <!--
|
---|
128 | <sect2>
|
---|
129 | <title>Multiple Network Interfaces</title>
|
---|
130 |
|
---|
131 |
|
---|
132 | </sect2>
|
---|
133 | -->
|
---|
134 |
|
---|
135 | <!-- These instructions are invalid on systemd because we don't use bootscripts.
|
---|
136 | In addition, we should probably verify that these are valid on SysV too.-->
|
---|
137 |
|
---|
138 | <sect2 revision="sysv">
|
---|
139 | <title>Devices for Servers</title>
|
---|
140 |
|
---|
141 | <para>
|
---|
142 | In some cases, it makes sense to disable
|
---|
143 | <application>udev</application> completely and create static devices.
|
---|
144 | Servers are one example of this situation. Does a server need the
|
---|
145 | capability of handling dynamic devices? Only the system administrator
|
---|
146 | can answer that question, but in many cases the answer will be no.
|
---|
147 | </para>
|
---|
148 |
|
---|
149 | <para>
|
---|
150 | If dynamic devices are not desired, then static devices must be
|
---|
151 | created on the system. In the default configuration, the
|
---|
152 | <filename>/etc/rc.d/rcS.d/S10udev</filename> boot script mounts a
|
---|
153 | <systemitem class="filesystem">tmpfs</systemitem> partition over the
|
---|
154 | <filename class="directory">/dev</filename> directory. This problem can
|
---|
155 | be overcome by mounting the root partition temporarily:
|
---|
156 | </para>
|
---|
157 |
|
---|
158 | <warning>
|
---|
159 | <para>
|
---|
160 | If the instructions below are not followed carefully, your
|
---|
161 | system could become unbootable.
|
---|
162 | </para>
|
---|
163 | </warning>
|
---|
164 |
|
---|
165 |
|
---|
166 | <screen><userinput>mount --bind / /mnt
|
---|
167 | cp -a /dev/* /mnt/dev
|
---|
168 | rm /etc/rc.d/rcS.d/{S10udev,S50udev_retry}
|
---|
169 | umount /mnt</userinput></screen>
|
---|
170 |
|
---|
171 | <para>
|
---|
172 | At this point, the system will use static devices upon the next
|
---|
173 | reboot. Create any desired additional devices using
|
---|
174 | <command>mknod</command>.
|
---|
175 | </para>
|
---|
176 |
|
---|
177 | <para>
|
---|
178 | If you want to restore the dynamic devices, recreate the
|
---|
179 | <filename>/etc/rc.d/rcS.d/{S10udev,S50udev_retry}</filename> symbolic
|
---|
180 | links and reboot again. Static devices do not need to be removed
|
---|
181 | (console and null are always needed) because they are covered by the
|
---|
182 | <systemitem class="filesystem">tmpfs</systemitem> partition. Disk
|
---|
183 | usage for devices is negligible (about 20–30 bytes per entry).
|
---|
184 | </para>
|
---|
185 |
|
---|
186 | </sect2>
|
---|
187 |
|
---|
188 | <sect2 id="dev-dvd">
|
---|
189 | <title>Devices for DVD Drives</title>
|
---|
190 |
|
---|
191 | <para>
|
---|
192 | If the initial boot process does not set up the
|
---|
193 | <systemitem>/dev/dvd</systemitem> device properly, it can
|
---|
194 | be installed using the following modification to the default udev rules.
|
---|
195 | As the <systemitem class="username">root</systemitem> user, run:
|
---|
196 | </para>
|
---|
197 |
|
---|
198 | <screen><userinput>sed '1d;/SYMLINK.*cdrom/ a\
|
---|
199 | KERNEL=="sr0", ENV{ID_CDROM_DVD}=="1", SYMLINK+="dvd", OPTIONS+="link_priority=-100"' \
|
---|
200 | /lib/udev/rules.d/60-cdrom_id.rules > /etc/udev/rules.d/60-cdrom_id.rules</userinput></screen>
|
---|
201 |
|
---|
202 | </sect2>
|
---|
203 |
|
---|
204 | </sect1>
|
---|