LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: sleeve

[==LFS精华系列==]实现 devfs

[复制链接]
发表于 2003-4-8 19:51:55 | 显示全部楼层

找到啦

devfs 内核支持
在系统上启用 devfs 的第一步比较简单:就是要使内核支持 devfs。为此目的,您需要一个 2.4 系列的内核。使用 make menuconfig 或者 make xconfig,转至 Code maturity level 选项部分并确保启用了 Prompt for development and/or incomplete code/drivers 选项。然后转至 File systems 内核配置部分,查找 /dev file system support (EXPERIMENTAL) 选项。选中它。您将会看到在您刚启用的选项下方,出现了两个附加选项。第一个选项控制 devfs 在内核引导时是否自动安装到 /dev。不要启用它,我们将用一个特殊脚本手动安装 /dev。 第二个选项,Debug devfs,也应该被禁用。

禁用 /dev/pts
当您在屏幕上看到 File systems kernel configuration 部分时,如果您碰巧启用了 /dev/pts file system for Unix98 PTYs 的支持,则禁用该支持。devfs 提供了相似的功能,所以您就不再需要 devpts 文件系统了。继续进行然后保存内核配置;我们很快就要编译并安装一个新的内核!最后,在进行下一步以前,检查一下在 /etc/fstab 中是否有 /dev/pts 项;如果有,把它注释掉,使它在启动时不再被安装。


推荐资料:http://www-900.ibm.com/developer ... m/l-fs5/index.shtml
发表于 2003-12-7 14:40:42 | 显示全部楼层
以前用得好好的,现在用以前的方法却行不通。
发表于 2003-12-7 16:30:06 | 显示全部楼层

[转载]高级文件系统实现者指南,第 5 部分

http://www-900.ibm.com/developer ... m/l-fs5/index.shtml

设置 devfs

Daniel Robbins (drobbins@gentoo.org)
总裁兼 CEO,Gentoo Technologies, Inc.
2001 年 10 月

    Linux 2.4 发行版能支持很多新的文件系统,包括 Reiserfs、XFS、GFS 和其它文件系统。这些文件系统听起来不错,但它们到底能做什么,擅长做什么,又如何在 Linux 生产环境中安全地着手使用这些文件系统呢?Daniel Robbins 通过演示如何在 Linux 2.4 系统下安装这些新的高级文件系统来回答这些问题。在这部分中,Daniel 将带您经历为系统准备 devfs 的整个过程。阅读完本文,将可以在系统上启用 devfs;在下一篇文章里 Daniel Robbins 将介绍 devfs 最终安装的细节。

在上一部分(第 4 部分)中,我们具体讨论了什么是 devfs,以及它是如何解决几乎所有的设备管理问题的。现在是在您的系统上启动和运行 devfs 的时候了。在本文中,我们将使您的系统为启用 devfs 作好准备,在下篇文章中,我们将真正开始向 devfs 的转换。即使在 devfs 的下一篇(也是最后一篇)出版以前,您也完全可以遵循本文中的步骤,因为当我们完成了所有这些步骤之后,您的系统将仍旧继续正常运行 — 它仅仅为即将来临的 devfs 转换作好了准备。因此,没有必要因为后继文章还未出现而不遵循这些步骤。

请注意: 因为我们将对 Linux 系统的几个部分作出相当大的更改,所以确实可能搞糟您的系统。因此,如果您在对 Linux 系统内部更改方面没有经验的话,毫无疑问您应该在一个无关紧要的 Linux 机器上这样做,至少第一次应该这样。

需求
要启动和运行 devfs,需要使用 Linux 2.4 的一些版本(2.4.6 或 2.4.8 就不错)以及 glibc 2.1.3 或更高版本。还建议您使用 Xfree86 4.0 或更高版本,如果您的系统版本较低,建议您首先升级到 Xfree86 4.1。

紧急 bash 救援
在下篇文章中,我们将更改 Linux 系统中对启动至关重要的部分。既然完全可能因某个错误而使您偶尔搞糟引导过程,我将在本文首先讲述:如何用紧急 bash shell 命令启动和运行系统。如果您确实碰巧发现系统因为 init 脚本或 /sbin/init 本身的问题而不能引导,就可以使用这个紧急引导过程。

进行紧急引导最简单的方法是:在引导时刻使用 GRUB 或 LILO 把 init=/bin/bash 选项传递给内核。 如果使用 GRUB,您应该能够通过点击 e 来实时地编辑当前菜单项,从而在需要时交互地传递该选项。如果使用 LILO,则确保在继续下一步之前,您已知道如何向内核传递启动选项,必要时,还要创建一个新的“紧急”LILO 启动选项。

过程
这样,基本的“救援”过程如下。首先,将 init=/bin/bash 作为一个内核引导选项传递给内核。当内核引导时,它将以 /bin/bash 而不是通常的 /sbin/init 作为第一个进程启动。 您不会被提示进行登录就看到一个 root 用户 bash 提示符:

#

然而,尽管您看到一个 root bash 提示符,实际上只安装了根文件系统,而且仅以只读的形式安装。下面介绍在这之后如何启动和运行您的系统。如果文件系统没有卸装干净的话,应该首先对它们进行 fsck。首先对根文件系统执行 fsck -a,然后 fsck -R -A -a 就会负责处理所有其它的文件系统:

# fsck -a /dev/hda1
# fsck -R -A -a

既然文件系统已经一致(或者,如果文件系统在系统重引导时已经卸装干净,并且您跳过了上一步骤),我们可以简单地以可读写方式重新安装根文件系统并且安装 /proc,如下所示:

# mount / -o remount,rw
# mount /proc

然后,安装可能位于其它分区中的所有重要的文件系统树。例如,如果在另一个分区上有 /usr,则还要输入:

# mount /usr

如果您想做的不仅仅只是打开一个编辑器的话,则最好是激活交换分区。如果您使用 emacs,您可能会需要它

# swapon -a

现在,您应该能够使用您喜爱的编辑器来编辑任何需要编辑的文件,以便修复现有的引导问题。一旦完成,只需按安装时的顺序,以只读方式重新安装分区即可。例如,如果有一个单独的 /usr 分区,为使所有的文件系统处于一致的状态(准备重新引导),可以输入:

# mount /usr -o remount,ro
# mount / -o remount,ro

现在,您可以安全地重新引导了。但愿现在已经解决了引导问题,并且可以使用正常的 LILO 或 GRUB 选项启动和运行系统。

# /sbin/reboot -nfi

为 devfs 作好准备

devfs 配置
既然您知道了在紧急情况下该怎么做,我们就可以使系统为 devfs 做好准备了。在下一篇文章里,我们将对 Linux 系统作相对复杂的更改。为什么需要这样呢?因为我们不仅仅在内核中启用 devfs 功能,这的确非常容易。我们还将以一种特别方式设置 devfsd(设备管理守护进程),用它来备份和恢复任何对设备许可权和所有权的更改。我们需要用到很多小窍门来使这个新的系统极佳地工作。但是一旦实现,我想您将对这个结果 非常满意。

devfs 内核支持
在系统上启用 devfs 的第一步比较简单:就是要使内核支持 devfs。为此目的,您需要一个 2.4 系列的内核。使用 make menuconfig 或者 make xconfig,转至 Code maturity level 选项部分并确保启用了 Prompt for development and/or incomplete code/drivers 选项。然后转至 File systems 内核配置部分,查找 /dev file system support (EXPERIMENTAL) 选项。选中它。您将会看到在您刚启用的选项下方,出现了两个附加选项。第一个选项控制 devfs 在内核引导时是否自动安装到 /dev。不要启用它,我们将用一个特殊脚本手动安装 /dev。 第二个选项,Debug devfs,也应该被禁用。

禁用 /dev/pts
当您在屏幕上看到 File systems kernel configuration 部分时,如果您碰巧启用了 /dev/pts file system for Unix98 PTYs 的支持,则禁用该支持。devfs 提供了相似的功能,所以您就不再需要 devpts 文件系统了。继续进行然后保存内核配置;我们很快就要编译并安装一个新的内核!最后,在进行下一步以前,检查一下在 /etc/fstab 中是否有 /dev/pts 项;如果有,把它注释掉,使它在启动时不再被安装。

各种配置风格
下一步,将 /etc/securetty 文件装入编辑器。该文件由 login 使用,它允许您指定允许 root 用户使用以进行登录的 ttys。通常,它包含从 tty1 到 tty12 的设备,每行一个。为了使这个文件适用于 devfs,您应当为这些 ttys 加入适当的 devfs 类型名字,并保留原有的 tty? 名字,以备日后您决定禁用 devfs 引导之需。把以下几行添加到 /etc/securetty 的最下面。

vc/1
vc/2
vc/3
vc/4
vc/5
vc/6
vc/7
vc/8
vc/9
vc/10
vc/11
vc/12

安装 devfsd
接下来就是在系统上安装 devfsd,即 devfs 助手守护进程。Devfsd 将会负责创建“旧类型”兼容性设备节点;在注册/注销设备时执行自动化操作;负责备份对根文件系统上某个目录的设备许可权和所有权的更改,以及其它更多功能。现在,我们将只安装 devfsd;在下一篇文章中,我们将使它和 devfs 一起启动和运行。为了安装 devfsd,首先需要下载最新版本的 devfsd 压缩文件。(请参阅本文后面的参考资料),当前版本为 1.3.16。然后执行下列步骤:

# tar xzvf devfsd-1.3.16.tar.gz
# cd devfsd
# make

现在,devfsd 应该编译好并可以安装了。如果您的帮助手册页存储在 /usr/man 中,输入 make install;如果您正在使用 FHS 兼容系统,并且您的帮助手册页存储在 /usr/share/man 中,输入 make mandir=/usr/share/man install。现在将安装 Devfsd,但还未运行,这正是我们现在要做的。
安装注释
我们即将配置 devfsd,以便完全支持兼容性设备,所以tty? 应该足够了。然而,小心驶得万年船,尤其在可能会影响到 login 是否允许超级用户进入系统的时候。用我们的方法,即使存在问题而且 devfsd 无法启动,超级用户在 login: 提示符下登录时也不会有问题,哪怕已经启用了 devfs。

启动新内核
现在,继续前进,编译并安装刚刚配置好的内核。这个内核应该是您现在内核的临时替代品;它应能正常引导;并且尽管它内置了 devfs 支持,您应该觉察不出它与您现在正在运行的内核有什么差别。一旦新内核安装完毕,重新引导系统以确保到目前为止一切工作正常。

Devfs 配置方法
您的系统现在已经作好了向 devfs 转换的准备,我将在下一篇文章中详细介绍。现在,是熟悉一下我们正在使用的方法的时候了。您将看到,用 devfs 启用系统可能会很棘手,尤其当您使用到 devfs 的所有优点(如持久的许可权和所有权)的时候。

内核自动安装带来的问题
确实有很多方法来使系统 devfs 启用。其中之一就是让内核在引导时自动将 devfs 安装到 /dev;我们将不使用此选项,尽管这样确实是可以的。乍看起来,这种方法似乎很有意义,因为它可以保证所有 devfs 类型的设备对于所有进程都是可用的,甚至对第一个进程 /sbin/init 也是如此。然而,这种方法有一个问题。尽管 devfs 提供所有“新类型”的设备,但旧类型的设备节点却是由 devfsd 守护进程创建。devfsd 不是由内核启动的,所以即使让内核在引导时安装 devfs ,当 /sbin/init 启动时我们仍然只会得到部分而非所有的设备节点。这就意味着为了使 devfsd 能在恰当的时间启动和运行,您必须修改系统初始化脚本。这不但棘手(因为这需要对系统启动脚本有专家级的理解),而且这种方法还存在其它问题。

内核安装方法的主要的问题是,devfsd 只有在能够访问原来旧类型磁盘上的 /dev 目录下的内容时,才能最好地工作。我们允许访问原来的旧类型设备的典型办法是,在 devfs 自身被安装到 /dev 之前,绑定安装 /dev 到另一个位置(通常是 /dev-state)。

这样就确保了即使在安装了 devfs 以后,也可以在 /dev-state 中访问旧的 /dev,这就允许 devfsd 将该目录用于持久设备存储。理解这点很重要,即如果没有绑定安装的话,/dev 里的旧内容将不可访问,因为在 /dev 安装 devfs 时实际上会覆盖它们。这就是用内核安装 devfs 存在的问题。如果 kernel 在任何其它进程能够启动之前就在 /dev 安装 devfs 文件系统的话,那么我们就没有机会执行绑定安装,/dev 的最初内容也就被完全隐藏。这很不友善,是吗?(想知道更多绑定安装的内容,请参阅本系列的第 3 部分。

最佳解决方案
理想的情况是:我们能在 /sbin/init 一启动时就能拥有完整的设备节点(新类型和兼容性设备),并且有机会在安装 devfs 以前将 /dev 绑定安装到另一位置。但如何才能做到这点?

初始封装器
一个方法是添加一个内核补丁来执行从 /dev 到 /dev-state 的绑定安装。然而,尽管这完全可行,而且也确实很容易执行,手工为您安装的每个 Linux 内核打补丁仍是相当麻烦的。因此,解决 devfs 的“先有鸡还是先有蛋”问题的最好办法,可能就是使用初始封装器。对于我们这个特别的应用而言,初始封装器就是一个 bash 脚本,它代替 /sbin/init — 而真正的 init 则已被重命名为 /sbin/init.system。简而言之,初始封装器将做以下事情:

#!/bin/bash
mkdir -f /dev-state
mount --bind /dev /dev-state
mount -t devfs none /dev
devfsd /dev
exec /sbin/init.system

正如您所见,初始封装器所做的第一件事就是确保 /dev-state 存在。然后将 /dev 树绑定安装到 /dev-state,以便可以通过 /dev-state 目录使用 /dev 的内容。然后,在 /dev 之上安装我们的 devfs 文件,然后启动 devfsd,以便自动在 devfs 中注册我们的兼容性设备。 最后,我们 exec 最初的 /sbin/init ,现在它已被重命名为 /sbin/init.system。exec 命令使 init.system 取代正在运行的 bash 进程。这意味着我们的 bash 脚本被终止,而 init.system 继承了标识符为 1 的进程,也就是 init 进程以前被占用的进程标识。当 /sbin/init.system 启动后,系统将正常引导,devfs 现在也已经完全可操作了;通过使用初始封装器,我们不必给内核打补丁,不必修改启动脚本,也不必为只有一半可操作的 devfs 系统而伤脑筋了。

在我的下一篇文章中,我将指导您经历启动和运行完整版本的初始封装器的整个过程,并为您演示如何利用 devfsd 的众多强大特性。请继续阅读!

参考资料

    * 请阅读 Daniel 这个系列前面的文章,他描述了:
          o 日志和 ReiserFS 的好处(第 1 部分)
          o 如何安装 ReiserFS 系统(第 2 部分)
          o 如何使用虚拟内存(VM)文件系统和绑定安装(第 3 部分)
          o devfs(设备管理文件系统)的好处(第 4 部分)

    * 下载最新版本的 devfsd 压缩文件,目前版本 1.3.16.

    * 对于想大体学习更多有关设备注册和 Linux 设备驱动程序编程的人而言,O'Reilly 的 Linux Device Drivers,2nd Edition 是一本极好的书,也是很好的资源。

    * 务必阅读 Linux devfs 的创始人 Richard Gooch 编著的 Linux Devfs FAQ。它是完全的、详细的,并且是最新的。还要看更多的吗?可能要访问 Richard Gooch 的主页; 里面有 devfs 和其它一些很棒的东西。

    * 通过向 majordomo@oss.sgi.com 发送一封电子邮件并在消息正文写上 subscribe 来订阅 devfs 邮递列表。请查看 devfs 列表档案。

    * 可以在 GNU GRUB 项目页面找出更多关于 GRUB 的内容。还有更好的呢,请查看 Daniel 有关安装和使用 GRLB 的 developerWorks 教程。

    * 您是一个 LILO 用户吗?别担心,我们没有忘记您!快去下载 LILO 的最近版本吧。

    * Linux 每周新闻可以让您跟上内核最新发展。

    * 在 developerWorks 浏览更多 Linux 资源。

    * 在 developerWorks 浏览 更多开放源码资源。



作者简介
Daniel Robbins 居住在美国新墨西哥州的阿尔布克尔克(Albuquerque),他是 Gentoo Technologies,Inc. 的总裁兼 CEO,他是 Gentoo Linux(用于 PC 的高级 Linux)的创始人,以及 Portage 系统(Linux 的下一代移植系统)的创始人。 他还是 Macmillan 出版的几本书 Caldera OpenLinux Unleashed、SuSE Linux Unleashed 和 Samba Unleashed 的投稿人。Daniel 自小学二年级起就和计算机结下不解之缘,那时他第一次接触 Logo 编程语言,并沉溺于 Pac-Man 游戏中。这也许就是为什么至今他仍担任 SONY Electronic Publishing/Psygnosis 的“首席图形设计师”的原因所在。Daniel 喜欢与妻子 Mary 和他们的女儿 Hadassah 一起共度时光。您可以发邮件到 drobbins@gentoo.org 与他联系。
发表于 2003-12-7 17:27:41 | 显示全部楼层
good,好好研究一下。
谢谢版主!
发表于 2003-12-7 18:29:02 | 显示全部楼层

回复: [转载]高级文件系统实现者指南,第 5 部分

最初由 tram 发表
http://www-900.ibm.com/developer ... m/l-fs5/index.shtml

设置 devfs

Daniel Robbins (drobbins@gentoo.org)
总裁兼 CEO,Gentoo Technologies, Inc.
2001 年 10 月
.
.
.



要像tram兄一样,学会找资料才行,。:)。。谢谢
发表于 2003-12-7 22:18:55 | 显示全部楼层
呵呵,大家向版主学习ing ..............以后我们也来当当版主。
发表于 2003-12-9 16:01:48 | 显示全部楼层
采用了ibm900上面所介绍的方法也是不能启动。
跟sleeve所说的方法一样,devfsd已经启动起来以后,却读不到/dev 里面的内容,所以根本无法启动。
发表于 2003-12-9 19:30:41 | 显示全部楼层
好像lfs的hints有提的。。。。


AUTHOR: Mark Ellis (markp.ellis@virgin.net)

DATE: 2003-09-23

LICENSE: GNU Free Documentation License Version 1.2

SYNOPSIS: How to use kernel module autoloading with devfs and devfsd

DESCRIPTION:
Kernel module autoloading with modutils requires a slightly different approach
when using devfs rather than a static /dev. This hint explains how to configure
your modutils for devfs(d).

PREREQUISITES:
Almost any system should do, providing you enabled devfs in the kernel.

HINT:
Devfs is a virtual filesystem, like /proc, that an appropriately configured
kernel generates to replace the device nodes found in /dev, used to access the
hardware, but you probably already knew that. For more see

  http://www.atnf.csiro.au/people/rgooch/linux/

the kernel docs

  linux/Documentation/filesystems/devfs

and the devfs hint at linuxfromscratch.

A common problem when using devfs appears to be the use of auto loaded kernel
modules that are associated with device nodes under /dev. It's a chicken and egg
problem, modules are loaded when the node is accessed in /dev, but until the
module loads there is no device node. This hint attempts to explain how auto
loading using devfs is done the way it was intended, the "intended" part being
important because there are a number of workarounds, all of which duplicate to a
certain extent functionality that is already present.

All of this is to my personal understanding, particulary the why's, which I have
deduced from scatterings of documentation and the functionality i have found.
If anyone knows that it is wrong, mistaken or otherwise, please shout

Throughout this hint I'm going to use ALSA, the Advanced Linux Sound
Architecture modules, as an example, primarily because they are the most complex
set of modules i have come across and involve practically everything you need to
know about modules, and also because it crops up time and again on the BLFS
support mailing list. This hint will probably look like it is actually for ALSA,
but everything here should hopefully be applicable to any kernel module.


1) Aliasing device nodes to modules
-----------------------------------

I'm assuming you know the basics of module configuration, particularly aliases,
using /etc/modules.conf. If not, go and have a look at the modutils
documentation.

The ALSA documentation gives a basic setup for autoloading modules using a
normal /dev directory, it looks something like this :-

       alias char-major-116 snd
       options snd snd_major=116 snd_cards_limit=1
       alias snd-card-0 snd-<your sound card>
       options snd-<your sound card> snd_index=0 snd_id="GusPnP"

The important part for us is the first line, which essentially says, when a
device node is accessed that has a major number of 116, we need the module
called snd.o. This won't work with devfs because we dont have the device file
until the module is loaded.

This issue is addressed by devfsd, the devfs daemon. A lot of people think
that devfsd is only needed to provide all those backwards compatible symlinks
for non-devfs aware applications, but it also helps fix this non-existent
device file problem, which devfs alone cannot do. You'll therefore need to
start devfsd at boot, see the appendix if you don't already have it set up.

Now for a more helpful alias in modules.conf.

        alias snd-card-0 snd-<your sound card>
        alias /dev/snd* snd-card-0

ALSA with devfs puts all the native sound device files in the /dev/snd/
directory, so now whenever a node in /dev/snd/, or the directory itself, is
accessed, and that includes listing the directory, devfsd notices the node
does not exist, finds that the node(s) are aliased to module snd-whatever,
and requests that the module be loaded. The module creates the device nodes
and the application never knows they weren't there a second ago.


An alternative to aliasing in modules.conf is available, using the devfsd
configuration file /etc/devfsd.conf directly. I prefer the method above, it
comes across as being a little more straightforward, but if you want to try
something like :-

        LOOKUP snd MODLOAD snd-<your sound card>

in devfsd.conf, this should give similar results.


Enabling OSS emulation with ALSA requires a little more work. The ALSA
documentation says :-

        alias sound-slot-0 snd-card-0
        alias sound-service-0-0 snd-mixer-oss
        alias sound-service-0-1 snd-seq-oss
        alias sound-service-0-3 snd-pcm-oss
        alias sound-service-0-8 snd-seq-oss
        alias sound-service-0-12 snd-pcm-oss

The first number in "sound-service-?-?" corresponds to the number of the sound
card, in many cases literally the slot it occupies on the motherboard, and
corresponds to the "sound-slot-?" entry.
The second number is the minor number of the corresponding device file, so
/dev/sound/dsp has a minor number of 3, and requires the snd-pcm-oss module. In
devfs speak this translates to :-

        alias /dev/sound/mixer snd-mixer-oss
        alias /dev/sound/sequencer* snd-seq-oss
        alias /dev/sound/dsp* snd-pcm-oss
        alias /dev/sound/audio* snd-pcm-oss
        alias /dev/sound/adsp* snd-pcm-oss
        alias /dev/sound* snd-card-0

Note that the least specific match, /dev/sound*, must be at the end of the
sequence, or the more specific entries will effectively be ignored.

Note that different sound cards will support different features, and these
entries may be more than enough or insufficient for your needs. I deduced most of
these using an ISA PnP SoundBlaster 16, but the adsp* entry isn't relevant for
me, it came out of devices.txt in the kernel documentation, must reading for any
LFSer If you have problems with specific features of your card under OSS
emulation, manually modprobe each oss mudule in turn and see what devices it
creates.

If you want your entries in devfsd.conf rather than modules.conf :-

        LOOKUP sound MODLOAD snd-<your sound card>
        LOOKUP sound/mixer MODLOAD snd-mixer-oss
        LOOKUP sound/sequencer MODLOAD snd-seq-oss
        LOOKUP sound/dsp MODLOAD snd-pcm-oss
        LOOKUP sound/audio MODLOAD snd-pcm-oss
        LOOKUP sound/adsp MODLOAD snd-pcm-oss



You should hopefully now have a setup that will at least auto load modules for
sound applications, run as root, that can work with devfs naming schemes.


2) Adding entries for backward compatibility
--------------------------------------------

Alas many applications do not yet support the relatively new naming scheme
used by devfs. In some cases it is easy to re-configure these programs
to point to the new namespace, and for the rest devfsd will happily create
a host of symlinks to point from the old names to the new. However, it must be
told which of the old names correspond to modules that need to be loaded, in the
same way as the 'true' devices. It's easy to find out what you need, just
modprobe the modules by hand and see where the symlinks go.

Native ALSA devices all live in /dev/snd/ whether you use devfs or a static
/dev, so you'll only need backwards compatibility for OSS devices :-

        alias /dev/mixer snd-mixer-oss
        alias /dev/sequencer* snd-seq-oss
        alias /dev/dsp* snd-pcm-oss
        alias /dev/audio* snd-pcm-oss
        alias /dev/adsp* snd-pcm-oss

        alias /dev/dmfm snd-card-0
        alias /dev/dmmidi snd-card-0
        alias /dev/midi00 snd-card-0

Notice the last three entries. With the old naming scheme there is no common
element we can use to autoload the basic functionality, such as a shared
directory name, so each entry must be listed individually.

So assuming you remembered to turn on compatibility mode in devfsd (the first
REGISTER/UNREGISTER lines in devfsd.conf), accessing /dev/dsp will load the
oss module and create a symlink to /dev/sound/dsp.

Again, if you'd rather use devfsd.conf :-

        LOOKUP mixer MODLOAD snd-mixer-oss
        LOOKUP sequencer MODLOAD snd-seq-oss
        LOOKUP dsp MODLOAD snd-pcm-oss
        LOOKUP audio MODLOAD snd-pcm-oss
        LOOKUP adsp MODLOAD snd-pcm-oss

        LOOKUP dmfm MODLOAD snd-<your sound card>
        LOOKUP dmmidi MODLOAD snd-<your sound card>
        LOOKUP midi00 MODLOAD snd-<your sound card>



3) More configuration
---------------------

You've got your modules autoloading by device entry, and compatibility
symlinks, which is sufficient for many uses.

Devfs by default creates device nodes owned by user and group root,
with restrictive permissions in most cases, not much use unless you like
danger and always login as root

For our ALSA setup, a good solution is to create an 'audio' group and
give its members read/write access to the audio devices. The following
in devfsd.conf accomplishes just that:-

        REGISTER       ^sound$                PERMISSIONS root.audio 0750
        REGISTER       ^sound/.*        PERMISSIONS root.audio 0660
        REGISTER       ^snd$                PERMISSIONS root.audio 0750
        REGISTER       ^snd/.*                PERMISSIONS root.audio 0660

If you use compatibility symlinks and find the permissions on these are
not to your liking, remember to add entries for these as well.


Finally, since modules may be loaded and unloaded a number of times,
any extra configuration related to devices may be lost, hence the
'post-install' and 'pre-remove' entries in modules.conf, which
do exectly that, run arbitrary commands after module loading and
before unloading. The ALSA sound channels are muted by default,
you must unmute them the first time they are used. To retain your
volume settings, in modules.conf use :-

post-install snd-sb16 /usr/sbin/alsactl restore
pre-remove snd-sb16 /usr/sbin/alsactl store

which store the settings when the modules are unloaded, and restore
them the next time the modules are loaded.

For other modules these commands can be anything you like. For example
when i hotplug my USB mouse, the hotplug system inserts the
appropriate modules, then i have a post-install entry to start gpm.


Appendix
--------
Installing devfsd is easy. Get it from the devfs web page above.
After unpacking, edit the GNUmakefile for stuff like CFLAGS if you
want, then just:-

make
make install

which puts the daemon in /sbin and a couple of config files in /etc.

Make an addition to your bootscripts to run '/sbin/devfsd /dev' as the
very first thing that happens. Thats it !

The default devfsd.conf enables all those compatibility symlinks. If
you don't need them comment out the first REGISTER/UNREGISTER lines.


CHANGELOG:
[2002-08-15]
* Initial hint.
[2003-09-23]
* updated to new format.
* minor text changes.
* added /dev/sound* wildcard
* new contact email
* more descriptive name
发表于 2003-12-9 19:49:35 | 显示全部楼层
哦,谢谢,刚刚又试了一把,居然好了。又可以用了。晕死了。
只不过是更新了一把内核。然后又做成跟以前的一样的配置。
发表于 2003-12-9 21:05:51 | 显示全部楼层
呵呵,其实并不是这个原因,而是因为/etc/devfsd.conf及/etc/fstab的问题。
当devfsd启动以后,根本没有建立起/dev/hda*这样的连接,而是只有
/dev/ide/bus0/target0/lun0/part*这样的设备点而已。而/etc/fstab里面所写的分区格式为/dev/hda*这样的,所以swapon程序根本找不到有/dev/hda*这样的连接,或者是设备,所以交换分区就启动不了。
解决办法就是将fstab文件里面的关于交换分区的那一条记录改成交换分区的旧的设备文件。这样就可以启动,而主分区及其实分区则不用进行改动。系统在swapon之后,好像就建立了 /dev/hda*这样的符号连接,就可以找到了。
     还有以前关于用 df命令的时候显示出来的是/dev/ide/host0........这样的方式,也是因为/etc/devfsd.conf这个文件的原因。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表