Files
master/chapter07/symlinks.html
2015-05-23 18:50:06 +08:00

90 lines
5.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title> 7.4.&nbsp;Creating Custom Symlinks to Devices </title>
<link rel="stylesheet" type="text/css" href="../stylesheets/lfs.css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="stylesheet" href="../stylesheets/lfs-print.css"
type="text/css" media="print">
</head>
<body class="lfs" id="lfs-7.7-systemd">
<div class="navheader">
<h4> Linux From Scratch - Version 7.7-systemd </h4>
<h3> Chapter&nbsp;7.&nbsp;Basic System Configuration </h3>
<ul>
<li class="prev"> <a accesskey="p" href="udev.html"
title="Device and Module Handling on an LFS System">上一页</a>
<p> LFS 系统上的设备和模块处理 </p>
</li>
<li class="next"> <a accesskey="n" href="clock.html"
title="Configuring the system clock">下一页</a>
<p> Configuring the system clock </p>
</li>
<li class="up"> <a accesskey="u" href="chapter07.html"
title="Chapter&nbsp;7.&nbsp;Basic System Configuration">返回</a>
</li>
<li class="home"> <a accesskey="h" href="../index.html"
title="Linux From Scratch - Version 7.7-systemd">主页</a> </li>
</ul>
</div>
<div class="sect1" xml:lang="en" lang="en">
<h1 class="sect1"> <a id="ch-scripts-symlinks"
name="ch-scripts-symlinks"></a>7.4. 创建自定义符号连接设备 </h1>
<div class="sect2" xml:lang="en" lang="en">
<h2 class="sect2"> 7.4.1. 处理相似性质的设备 </h2>
<p> 正如 <a class="xref" href="udev.html" title="7.3.&nbsp;Device
and Module Handling on an LFS System">Section&nbsp;7.3, “LFS
系统上的设备和模块处理 ”</a> 节中解释的,具有相同功能的设备出现在 <code class="filename">/dev</code>
目录下的顺序是随机的。假如你有一个 USB 摄像头和一个电视调谐器,<code class="filename">/dev/video0</code>
有可能是 USB 摄像头,<code class="filename">/dev/video1</code>
是电视调谐器,有时候又可能是反过来的。对于除声卡和网卡外的设备,都可以通过创建自定义持久性符号链接的 udev
规则来固定。网卡如何设置请看 <a class="xref" href="network.html"
title="7.2.&nbsp;General Network Configuration">7.2,
“通用网络配置”</a>,网卡的相关设置请看 <a class="ulink"
href="http://www.linuxfromscratch.org/blfs/view/systemd/postlfs/devices.html">BLFS</a>
</p>
<p> 对于你所有的硬件,都有可能遇到此问题(尽管此问题可能在你当前的 Linux 发行版上不存在),在 <code></code><code
class="filename">/sys/class</code><code class="filename">/sys/block</code>
目录下找到对应目录,比如,显卡可能的路径为 <code class="filename">/sys/class/video4linux/video<em
class="replaceable"><code>X</code></em></code>。找到该设备的唯一设备标
usually, vendor and product IDs and/or serial numbers work</p>
<pre class="userinput"><kbd class="command">udevadm info -a -p /sys/class/video4linux/video0</kbd>
</pre>
<p> 然后通过写入规则建立符号链接:</p>
<pre class="userinput"><kbd class="command">cat &gt; /etc/udev/rules.d/83-duplicate_devs.rules &lt;&lt; "EOF"
<code class="literal">
# Persistent symlinks for webcam and tuner
KERNEL=="video*", ATTRS{idProduct}=="1910", ATTRS{idVendor}=="0d81", \
SYMLINK+="webcam"
KERNEL=="video*", ATTRS{device}=="0x036f", ATTRS{vendor}=="0x109e", \
SYMLINK+="tvtuner"
</code>
EOF</kbd>
</pre>
<p> 最终,<code class="filename">/dev/video0</code><code
class="filename">/dev/video1</code> 依旧会随机分配给 USB
摄像头和电视调谐器,但是 <code class="filename">/dev/tvtuner</code><code
class="filename">/dev/webcam</code> 将会固定的分配给正确的设备。</p>
</div>
</div>
<div class="navfooter">
<ul>
<li class="prev"> <a accesskey="p" href="udev.html"
title="Device and Module Handling on an LFS System">上一页</a>
<p> LFS 系统上的设备和模块处理 </p>
</li>
<li class="next"> <a accesskey="n" href="clock.html"
title="Configuring the system clock">下一页</a>
<p> Configuring the system clock </p>
</li>
<li class="up"> <a accesskey="u" href="chapter07.html"
title="Chapter&nbsp;7.&nbsp;Basic System Configuration">返回</a>
</li>
<li class="home"> <a accesskey="h" href="../index.html"
title="Linux From Scratch - Version 7.7-systemd">主页</a> </li>
</ul>
</div>
</body>
</html>