modules.conf的原理

来源:互联网 发布:布莱克书店知乎 编辑:程序博客网 时间:2024/05/13 10:23

当然还是看man更具体,但是,还是要大致说一说他们的功能来做个指引,以后就可以有所指引,就可以知道查什么了?

  modeprobe和insmode都可以安装库,但是,modeprobe会议靠分析库之间的依赖关系,然后又先后顺序的加载必需的库,然后再加载当前的库,而insmode就只会加载你所制定的这个库,一旦他有一些依赖关系,那么你就无从下手了,会出错的。
  库之间的依赖关系并不是modeprobe自己检测出来的,是depmode检测书来的,并写在了类似/lib/modules/2.6.xx/modules.dep 得文件里面了。
  而/etc/conf.modules或者/etc/modules.conf文件里面描述了一些库的别名,加载库之前/之后要执行的命令,或者库之间的先后依赖关系,以及在加载库的时候提供的参数等信息,还可以制定一些路径作为加载某种库的时候的搜索路径。但是有个问题,depmode是通过读取/etc/modules.conf文件来获取库之间的依赖关系的么?应该说可以肯定的是/etc/modules.conf会对modeprobe和depmode的行为有影响,如对库的搜索路径就有影响。
    /etc/modules.conf会影响depmode和modeprobe,而depmode的结果又会为modeprobe所用。
 
   下面是对/etc/modules.conf的几个简单常用的statement:
    1. alias iso9660 isofs 是我们可以用insmode iso9660来代替isofs,这样可以使用更为易懂的名字。
    2. define VARIABLE WORD可以定义VARIABLE=WORD,即将其加入环境变量中,这个变量在整个session有效。
    3. include PATH_TO_CONFIG_FILE
    可以include别的config文件。结合if else 命令可以做到有条件的include,从而提高移植性。
    4. insmod_opt=GENERIC_OPTIONS_TO_INSMOD
     如果你需要为每次insmode的调用都提供一些公用的option,就可以加在这里。
    5. path[TAG]=A_PATH
    path里面记录了一些路径,我们可以加上个tag来讲路径分类,比如boot相关的库的路径就可以用path[boot]来制定,这样我们再modeprobe的时候就可以这样一下加载boot目录下的所有库:
      modprobe -t net
              Load one of the modules that are stored in the directory  tagged
              "net".  Each module are tried until one succeeds.

       modprobe -a -t boot
              All modules that are stored in directories tagged "boot" will be
              loaded.
     6. [add] probe name module_list

       [add] probeall name module_list
      意思不是很清楚,基本上就是说,当要加载name时,就在module_list里面一个一个加载,第一种会在找到一个成功加载之后停止,第2中知道把所有的加载一个遍。add的含义不是很清楚。
     7。[add] above module module_list
        [add] below module module_list
        上述2个就是指明了module和module_list里的所有module之间的依赖顺序,这个可以具体察看man手册。linux采用了module stack的概念来描述加载的先后顺序。
     8.下面几种是在加载库,卸载库前后要执行commande的情况。

       pre-install module command
              Execute command before installing the specified module.  See the
              below directive as well.

       install module command
              Execute command instead of the default  insmod  when  installing
              the specified module.

       post-install module command
              Execute  command after installing the specified module.  See the
              above directive as well.

       pre-remove module command
              Execute command before removing the specified module.   See  the
              above directive as well.

       remove module command
              Execute  command  instead  of  the default (built-in) rmmod when
              removing the specified module.

       post-remove module command
     9。 此外,在etc/modules.conf里面是可以使用shell的原字符的,meta-character,如可以使用`command`。
----------------------------------------------------

为什么我的modules.conf在2.6中不起作用。

modules-init-tools包已经装了,但是gen......好象不起作用,怎么办?
------------------------------------
使用如下命令将modules转换为modprobe.conf
/generate-modprobe.conf /etc/modprobe.conf
转换时可能会有警告,可以不理会它。转换完成后将modules.conf移除或更名。

修改/etc/rc.sysinit文件:
将其中所有的/proc/ksyms替换为/proc/kallsyms。
将其中所有的/proc/sys/kernel/modprobe 替换为/sbin/modprobe
在文件中mount -f /proc这一句下添加mount -f /sys
在文件中的action $"Mounting proc filesystem: " mount -n -t proc /proc /proc 这一句的下面添加 action $"Mounting sysfs filesystem: " mount -n -t sysfs /sys /sys

修改/etc/fstab文件:
加入none    /sys  sysfs   defaults  0 0

修改/etc/init.d/halt文件:
将halt_get_remaining函数内的awk '$2 ~ /^//$|^//proc|^//dev/{next}改为
awk '$2 ~ /^//$|^//proc|^//sys|^//dev/{next}

创建目录:
mkdir /sys

然后重启机器,模块的问题应该解决的差不多了。
原创粉丝点击