1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
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="ch-scripts-symlinks">
|
---|
9 | <?dbhtml filename="symlinks.html"?>
|
---|
10 |
|
---|
11 | <title>Creating Custom Symlinks to Devices</title>
|
---|
12 |
|
---|
13 | <sect2>
|
---|
14 |
|
---|
15 | <title>Dealing with duplicate devices</title>
|
---|
16 |
|
---|
17 | <para>As explained in <xref linkend="ch-scripts-udev"/>, the order in
|
---|
18 | which devices with the same function appear in
|
---|
19 | <filename class="directory">/dev</filename> is essentially random.
|
---|
20 | E.g., if you have a USB web camera and a TV tuner, sometimes
|
---|
21 | <filename>/dev/video0</filename> refers to the camera and
|
---|
22 | <filename>/dev/video1</filename> refers to the tuner, and sometimes
|
---|
23 | after a reboot the order changes to the opposite one.
|
---|
24 | For all classes of hardware except sound cards and network cards, this is
|
---|
25 | fixable by creating udev rules for custom persistent symlinks.
|
---|
26 | The case of network cards is covered separately in
|
---|
27 | <xref linkend="ch-scripts-network"/>, and sound card configuration can
|
---|
28 | be found in <ulink url="&blfs-root;view/svn/postlfs/devices.html">BLFS</ulink>.</para>
|
---|
29 |
|
---|
30 | <para>For each of your devices that is likely to have this problem
|
---|
31 | (even if the problem doesn't exist in your current Linux distribution),
|
---|
32 | find the corresponding directory under
|
---|
33 | <filename class="directory">/sys/class</filename> or
|
---|
34 | <filename class="directory">/sys/block</filename>.
|
---|
35 | For video devices, this may be
|
---|
36 | <filename
|
---|
37 | class="directory">/sys/class/video4linux/video<replaceable>X</replaceable></filename>.
|
---|
38 | Figure out the attributes that identify the device uniquely (usually,
|
---|
39 | vendor and product IDs and/or serial numbers work):</para>
|
---|
40 |
|
---|
41 | <screen role="nodump"><userinput>udevadm info -a -p /sys/class/video4linux/video0</userinput></screen>
|
---|
42 |
|
---|
43 | <para>Then write rules that create the symlinks, e.g.:</para>
|
---|
44 |
|
---|
45 | <screen role="nodump"><userinput>cat > /etc/udev/rules.d/83-duplicate_devs.rules << "EOF"
|
---|
46 | <literal>
|
---|
47 | # Persistent symlinks for webcam and tuner
|
---|
48 | KERNEL=="video*", ATTRS{idProduct}=="1910", ATTRS{idVendor}=="0d81", \
|
---|
49 | SYMLINK+="webcam"
|
---|
50 | KERNEL=="video*", ATTRS{device}=="0x036f", ATTRS{vendor}=="0x109e", \
|
---|
51 | SYMLINK+="tvtuner"
|
---|
52 | </literal>
|
---|
53 | EOF</userinput></screen>
|
---|
54 |
|
---|
55 | <para>The result is that <filename>/dev/video0</filename> and
|
---|
56 | <filename>/dev/video1</filename> devices still refer randomly to the tuner
|
---|
57 | and the web camera (and thus should never be used directly), but there are
|
---|
58 | symlinks <filename>/dev/tvtuner</filename> and
|
---|
59 | <filename>/dev/webcam</filename> that always point to the correct
|
---|
60 | device.</para>
|
---|
61 |
|
---|
62 | </sect2>
|
---|
63 |
|
---|
64 | </sect1>
|
---|