source: chapter07/symlinksd.xml@ 35a5259

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 35a5259 was 35a5259, checked in by Bruce Dubbs <bdubbs@…>, 8 years ago

Optimize building merged books

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/merge@11076 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

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