[e73e361] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[6732c094] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
[e73e361] | 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 | <sect1info>
|
---|
| 12 | <othername>$LastChangedBy$</othername>
|
---|
| 13 | <date>$Date$</date>
|
---|
| 14 | </sect1info>
|
---|
| 15 |
|
---|
| 16 | <title>About Devices</title>
|
---|
| 17 |
|
---|
| 18 | <indexterm zone="postlfs-devices">
|
---|
| 19 | <primary sortas="e-etc-udev-rules">/etc/udev/rules.d</primary>
|
---|
| 20 | </indexterm>
|
---|
| 21 |
|
---|
| 22 | <para>Although most devices needed by packages in BLFS and beyond are set up
|
---|
| 23 | properly by <application>udev</application> using the default rules installed
|
---|
| 24 | by LFS in <filename class="directory">/etc/udev/rules.d</filename>, there are
|
---|
| 25 | cases where the rules must be modified or augmented.</para>
|
---|
| 26 |
|
---|
| 27 | <para condition="html" role="usernotes">User Notes:
|
---|
| 28 | <ulink url="&blfs-wiki;/aboutdevices"/></para>
|
---|
| 29 |
|
---|
| 30 | <sect2>
|
---|
| 31 | <title>Multiple Sound Cards</title>
|
---|
| 32 |
|
---|
[9f12e36] | 33 | <para>If there are multiple sound cards in a system, the "default"
|
---|
| 34 | sound card becomes random. The method to establish sound card order
|
---|
| 35 | depends on whether the drivers are modules or not. If the sound card
|
---|
[e73e361] | 36 | drivers are compiled into the kernel, control is via kernel command line
|
---|
[0e959c63] | 37 | parameters in <filename>/boot/grub/grub.cfg</filename>. For example,
|
---|
[9f12e36] | 38 | if a system has both an FM801 card and a SoundBlaster PCI card, the
|
---|
[e73e361] | 39 | following can be appended to the command line:</para>
|
---|
| 40 |
|
---|
| 41 | <screen><literal>snd-fm801.index=0 snd-ens1371.index=1</literal></screen>
|
---|
| 42 |
|
---|
| 43 | <para>If the sound card drivers are built as modules, the order can be
|
---|
| 44 | established in the <filename>/etc/modprobe.conf</filename> file
|
---|
| 45 | with:</para>
|
---|
| 46 |
|
---|
| 47 | <screen><literal>options snd-fm801 index=0
|
---|
| 48 | options snd-ens1371 index=1</literal></screen>
|
---|
| 49 |
|
---|
| 50 | </sect2>
|
---|
| 51 |
|
---|
[d20c871] | 52 | <sect2 id="usb-device-issues">
|
---|
| 53 | <title>USB Device Issues</title>
|
---|
| 54 |
|
---|
| 55 | <para>USB devices usually have two kinds of device nodes associated with
|
---|
| 56 | them.</para>
|
---|
| 57 |
|
---|
| 58 | <para>The first kind is created by device-specific drivers (e.g.,
|
---|
| 59 | usb_storage/sd_mod or usblp) in the kernel. For example, a USB mass storage
|
---|
| 60 | device would be /dev/sdb, and a USB printer would be /dev/usb/lp0. These
|
---|
| 61 | device nodes exist only when the device-specific driver is loaded.</para>
|
---|
| 62 |
|
---|
| 63 | <para>The second kind of device nodes (/dev/bus/usb/BBB/DDD, where BBB is
|
---|
[0e959c63] | 64 | the bus number and DDD is the device number) are created even if the device
|
---|
[d20c871] | 65 | doesn't have a kernel driver. By using these "raw" USB device nodes, an
|
---|
| 66 | application can exchange arbitrary USB packets with the device, i.e.,
|
---|
| 67 | bypass the possibly-existing kernel driver.</para>
|
---|
| 68 |
|
---|
| 69 | <para>Access to raw USB device nodes is needed when a userspace program is
|
---|
| 70 | acting as a device driver. However, for the program to open the device
|
---|
| 71 | successfully, the permissions have to be set correctly. By default, due to
|
---|
| 72 | security concerns, all raw USB devices are owned by user root and group
|
---|
| 73 | usb, and have 0664 permissions (the read access is needed, e.g., for lsusb
|
---|
| 74 | to work and for programs to access USB hubs). Packages (such as SANE and
|
---|
| 75 | libgphoto2) containing userspace USB device drivers also ship udev rules
|
---|
| 76 | that change the permissions of the controlled raw USB devices. That is, rules
|
---|
[a41f643] | 77 | installed by SANE change permissions for known scanners, but not printers.
|
---|
[d20c871] | 78 | If a package maintainer forgot to write a rule for your device,
|
---|
[a41f643] | 79 | report a bug to both BLFS (if the package is there) and upstream, and
|
---|
[d40737d] | 80 | you will need to write your own rule.</para>
|
---|
[d20c871] | 81 |
|
---|
| 82 | <para>There is one situation when such fine-grained access control with
|
---|
| 83 | pre-generated udev rules doesn't work. Namely, PC emulators such as KVM,
|
---|
| 84 | QEMU and VirtualBox use raw USB device nodes to present arbitrary USB
|
---|
| 85 | devices to the guest operating system (note: patches are needed in order to
|
---|
| 86 | get this to work without the obsolete /proc/bus/usb mount point described
|
---|
| 87 | below). Obviously, maintainers of these packages cannot know which USB
|
---|
| 88 | devices are going to be connected to the guest operating system. You can
|
---|
| 89 | either write separate udev rules for all needed USB devices yourself, or
|
---|
[a41f643] | 90 | use the default catch-all "usb" group, members of which can send
|
---|
[d20c871] | 91 | arbitrary commands to all USB devices. </para>
|
---|
[a41f643] | 92 |
|
---|
[d20c871] | 93 | <para>Before Linux-2.6.15, raw USB device access was performed not with
|
---|
| 94 | /dev/bus/usb/BBB/DDD device nodes, but with /proc/bus/usb/BBB/DDD
|
---|
| 95 | pseudofiles. Some applications (e.g., VMware Workstation) still use only
|
---|
| 96 | this deprecated technique and can't use the new device nodes. For them to
|
---|
| 97 | work, use the "usb" group, but remember that members will have unrestricted
|
---|
| 98 | access to all USB devices. To create the fstab entry for the obsolete
|
---|
| 99 | usbfs filesystem:</para>
|
---|
| 100 |
|
---|
| 101 | <screen><literal>usbfs /proc/bus/usb usbfs devgid=14,devmode=0660 0 0</literal></screen>
|
---|
| 102 |
|
---|
| 103 | <note><para>Adding users to the "usb" group is inherently insecure, as they
|
---|
| 104 | can bypass access restrictions imposed through the driver-specific USB
|
---|
| 105 | device nodes. For instance, they can read sensitive data from USB hard drives
|
---|
[a41f643] | 106 | without being in the "disk" group. Avoid adding users to this group, if
|
---|
[d20c871] | 107 | you can.</para></note>
|
---|
| 108 |
|
---|
| 109 | </sect2>
|
---|
| 110 |
|
---|
[e73e361] | 111 | <sect2>
|
---|
[826bacb5] | 112 | <title>Udev Device Attributes</title>
|
---|
[9f12e36] | 113 |
|
---|
[e73e361] | 114 | <para>Fine-tuning of device attributes such as group name and permissions
|
---|
| 115 | is possible by creating extra <application>udev</application> rules,
|
---|
[5e9adc53] | 116 | matching on something like this. The vendor and product can be found by
|
---|
| 117 | searching the <filename class='directory'>/sys/devices</filename> directory
|
---|
| 118 | entries or using <command>udevadm info</command> after the device has been
|
---|
| 119 | attached. See the documentation in the current
|
---|
| 120 | <application>udev</application> directory of
|
---|
[e73e361] | 121 | <filename class='directory'>/usr/share/doc</filename> for details.</para>
|
---|
[9f12e36] | 122 |
|
---|
[fdf8b6d0] | 123 | <screen><literal>SUBSYSTEM=="usb_device", SYSFS{idVendor}=="05d8", SYSFS{idProduct}=="4002", \
|
---|
| 124 | GROUP:="scanner", MODE:="0660"</literal></screen>
|
---|
| 125 |
|
---|
| 126 | <note><para>The above line is used for descriptive purposes only. The
|
---|
| 127 | scanner <application>udev</application> rules are put into place when
|
---|
| 128 | installing <xref linkend='sane'/>.</para></note>
|
---|
[9f12e36] | 129 |
|
---|
[e73e361] | 130 | </sect2>
|
---|
| 131 |
|
---|
| 132 | <!--
|
---|
| 133 | <sect2>
|
---|
| 134 | <title>Multiple Network Interfaces</title>
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 | </sect2>
|
---|
| 138 | -->
|
---|
| 139 |
|
---|
| 140 | <sect2>
|
---|
| 141 | <title>Devices for Servers</title>
|
---|
| 142 |
|
---|
| 143 | <para>In some cases, it makes sense to disable
|
---|
| 144 | <application>udev</application> completely and create static devices.
|
---|
| 145 | Servers are one example of this situation. Does a server need the
|
---|
| 146 | capability of handling dynamic devices? Only the system administrator can
|
---|
| 147 | answer that question, but in many cases the answer will be no.</para>
|
---|
| 148 |
|
---|
| 149 | <para>If dynamic devices are not desired, then static devices must be
|
---|
| 150 | created on the system. In the default configuration, the
|
---|
[e302a659] | 151 | <filename>/etc/rc.d/rcS.d/S10udev</filename> boot script mounts a
|
---|
[e73e361] | 152 | <systemitem class="filesystem">tmpfs</systemitem> partition over the
|
---|
| 153 | <filename class="directory">/dev</filename> directory. This problem can be
|
---|
| 154 | overcome by mounting the root partition temporarily:</para>
|
---|
| 155 |
|
---|
| 156 | <warning><para>If the instructions below are not followed carefully, your
|
---|
| 157 | system could become unbootable.</para></warning>
|
---|
[9f12e36] | 158 |
|
---|
[e73e361] | 159 |
|
---|
| 160 | <screen><userinput>mount --bind / /mnt
|
---|
| 161 | cp -a /dev/* /mnt/dev
|
---|
[f41f8b6] | 162 | rm /etc/rc.d/rcS.d/{S10udev,S50udev_retry}
|
---|
[e73e361] | 163 | umount /mnt</userinput></screen>
|
---|
| 164 |
|
---|
| 165 | <para>At this point, the system will use static devices upon the next
|
---|
| 166 | reboot. Create any desired additional devices using
|
---|
| 167 | <command>mknod</command>.</para>
|
---|
[9f12e36] | 168 |
|
---|
[e73e361] | 169 | <para>If you want to restore the dynamic devices, recreate the
|
---|
[f41f8b6] | 170 | <filename>/etc/rc.d/rcS.d/{S10udev,S50udev_retry}</filename> symbolic
|
---|
[e73e361] | 171 | links and reboot again. Static devices do not need to be removed (console
|
---|
| 172 | and null are always needed) because they are covered by the <systemitem
|
---|
| 173 | class="filesystem">tmpfs</systemitem> partition. Disk usage for devices is
|
---|
| 174 | negligible (about 20–30 bytes per entry.)</para>
|
---|
| 175 |
|
---|
| 176 | </sect2>
|
---|
| 177 |
|
---|
| 178 | </sect1>
|
---|