uTools-Manuals/docs/linux/modprobe.html
2019-04-21 11:50:48 +08:00

36 lines
2.7 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.

<h1 id="modprobe">modprobe</h1>
<p>自动处理可载入模块</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>modprobe命令</strong> 用于智能地向内核中加载模块或者从内核中移除模块。</p>
<p>modprobe可载入指定的个别模块或是载入一组相依的模块。modprobe会根据depmod所产生的相依关系决定要载入哪些模块。若在载入过程中发生错误在modprobe会卸载整组的模块。</p>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">modprobe(选项)(参数)</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">-a或--all载入全部的模块
-c或--show-conf显示所有模块的设置信息
-d或--debug使用排错模式
-l或--list显示可用的模块
-r或--remove模块闲置不用时即自动卸载模块
-t或--type指定模块类型
-v或--verbose执行时显示详细的信息
-V或--version显示版本信息
-help显示帮助。</code></pre>
<h3 id="参数">参数</h3>
<p>模块名:要加载或移除的模块名称。</p>
<h3 id="实例">实例</h3>
<p><strong>查看modules的配置文件</strong></p>
<pre><code class="language-bash">modprobe -c</code></pre>
<p>这里可以查看modules的配置文件比如模块的alias别名是什么等。会打印许多行信息例如其中的一行会类似如下</p>
<pre><code class="language-bash">alias symbol:ip_conntrack_unregister_notifier ip_conntrack</code></pre>
<p><strong>列出内核中所有已经或者未挂载的所有模块:</strong></p>
<pre><code class="language-bash">modprobe -l</code></pre>
<p>这里,我们能查看到我们所需要的模块,然后根据我们的需要来挂载;其实<code>modprobe -l</code>读取的模块列表就位于/lib/modules/`uname -r `目录中;其中<code>uname -r</code>是内核的版本,例如输出结果的其中一行是:</p>
<pre><code class="language-bash">/lib/modules/2.6.18-348.6.1.el5/kernel/net/netfilter/xt_statistic.ko</code></pre>
<p><strong>挂载vfat模块</strong></p>
<pre><code class="language-bash">modprobe vfat</code></pre>
<p>这里,使用格式<code>modprobe 模块名</code>来挂载一个模块。挂载之后用lsmod可以查看已经挂载的模块。模块名是不能带有后缀的我们通过<code>modprobe -l</code>所看到的模块,都是带有<code>.ko</code><code>.o</code>后缀。</p>
<p><strong>移除已经加载的模块:</strong></p>
<pre><code class="language-bash">modprobe -r 模块名</code></pre>
<p>这里移除已加载的模块和rmmod功能相同。</p>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->