⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 578-580.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Using Linux:Managing the Kernel</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0789716232//-->

<!--TITLE=Using Linux//-->

<!--AUTHOR=William Ball//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Que//-->

<!--CHAPTER=32//-->

<!--PAGES=578-580//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="575-578.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="581-583.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H4 ALIGN="LEFT"><A NAME="Heading9"></A><FONT COLOR="#000077">Listing Modules</FONT></H4>

<P>Listing modules is fairly easy; you simply issue the following command:

</P>

<!-- CODE SNIP //-->

<PRE>

<B>/sbin/lsmod</B>

</PRE>

<!-- END CODE SNIP //-->

<P>Output of the program on my system looks like this:

</P>

<!-- CODE //-->

<PRE>

[root&#64;jansmachine jwalter]# /sbin/lsmod

Module       Pages       Used by

ppa          1           1 (autoclean)

sd_mod       4           1 (autoclean)

scsi_mod     7        [ppa sd_mod] 2 (autoclean)

vfat         3           1 (autoclean)

fat          6        [vfat]1 (autoclean)

ne           2           1 (autoclean)

8390         2         &#8800; 0 (autoclean)

sound        19          0

</PRE>

<!-- END CODE //-->

<P>The entries followed by <TT>(autoclean)</TT> are modules managed by <TT>kerneld</TT>. Note that the <TT>sound</TT> module is not followed by this designation, even though it is listed in the <TT>/etc/conf.modules</TT> file. This is because the module is actually loaded from an <TT>init</TT> script when the system boots.</P>

<H4 ALIGN="LEFT"><A NAME="Heading10"></A><FONT COLOR="#000077">Creating Module Dependencies</FONT></H4>

<P>In many cases, loadable modules depend on one another to work&#151;for example, the SCSI CD-ROM driver requires that a SCSI adapter driver be loaded before the CD-ROM driver is loaded, so it can actually access the CD device. This is a critical function of the system, and the system must keep detailed information on which module requires another module to be loaded first. There is another advantage to having interdependent modules in a system&#151;common functionality can be built into one module, and provide this functionality to other, more specific modules. Both the SCSI and sound module systems work this way, as do some file system driver modules. For instance, the Windows 95 long-filename system, <TT>vfat</TT>, is essentially a modified version of the standard DOS filesystem. Thus it makes sense for the <TT>vfat</TT> module to use the functionality found in the <TT>msdos</TT> file system module for most of it functions. The benefit here is that the new module can take advantage of extremely well-tested, dependable code, and if a standard (non-<TT>vfat</TT>) <TT>msdos</TT> file system is mounted, there is no code being loaded twice.</P>

<P>The system automatically creates the module dependencies at boot-time. Under certain circumstances, it is convenient, or even necessary, to update the dependency information. It is usually done when installing modules that are not part of the standard kernel distribution, such as the latest versions of <TT>ftape</TT>, the module that provides access to QIC tape drives. You also want to run module dependencies if you have changed your <TT>modules.conf</TT> to include additional directories where modules are kept. This prevents surprises if there are errors or problems with the modules in the directories that have been added and the system is rebooted, since you&#146;ll see any error messages while the system is still in a state at which these problems can be fixed.</P>

<P>To have the system generate new module dependencies, log on as root and issue the following command:</P>

<!-- CODE SNIP //-->

<PRE>

/sbin/depmod -a

</PRE>

<!-- END CODE SNIP //-->

<P>The system searches the standard module directory trees and generates dependencies for every module it finds.

</P>

<P>If you want to keep certain modules in directories outside the standard module directory tree (<TT>/lib/modules/&lt;kernel-version&gt;</TT>, where <TT>&lt;kernel-version&gt;</TT> is the current version of the Linux kernel), you must add the following to the top of your <TT>modules.conf</TT> file and restart <TT>kerneld</TT>:</P>

<!-- CODE SNIP //-->

<PRE>

<B>keep</B>

<B>path=&lt;path name&gt;</B>

</PRE>

<!-- END CODE SNIP //-->

<P>Again, <TT>&lt;path name&gt;</TT> points to the directory where the additional modules are kept. The <TT>keep</TT> directive tells the module utilities to <I>append</I> the directory name to the module paths. If this directory is not there, the module path will be <I>replaced</I>, which most likely is not what you want.</P>

<H4 ALIGN="LEFT"><A NAME="Heading11"></A><FONT COLOR="#000077">Enabling Modules at Boot Time</FONT></H4>

<P>The module management utilities can be configured to load entire directories of modules at boot time. This is not the same as using <TT>initrd</TT> to get the kernel to pre-load modules.</P>

<P>This process is a viable alternative to listing individual modules to be loaded at boot time in init scripts, or to letting <TT>kerneld</TT> automatically load and unload them.</P>



<TABLE BORDER="2" BORDERCOLOR="#0000" ALIGN="CENTER">

<TR><TD><FONT SIZE="+1"><B>In case you forget&#133;</B></FONT>

<BR>The kernel must be able to read the hard disk to load modules at boot time, which means that this is <I>not</I> the place to put entries for the SCSI adapter drivers that your system boots from because by the time the kernel has booted, the drivers must already be loaded and initialized for Linux to read the hard disk. These SCSI drivers that allow your system to boot are loaded from the <I>initial ramdisk</I>.</TABLE>



<P><FONT SIZE="+1"><B><I>Loading a module at boot time by using modules.conf</I></B></FONT></P>

<DL>

<DD><B>1.</B>&nbsp;&nbsp;Create a directory in which these modules should be kept. Use something like <TT>/lib/modules/&lt;kernel version&gt;/boot</TT> to keep the modules with the kernel version they were compiled for, and also within the directory tree where the rest of the world expects to see modules.

<DD><B>2.</B>&nbsp;&nbsp;Copy the modules you need to load at boot time to the directory.

<DD><B>3.</B>&nbsp;&nbsp;Make sure the first line of <TT>/etc/conf.modules</TT> is the directive <TT>keep</TT>. You don&#146;t want your module utilities thinking that this is the <I>only</I> thing you want them to do.

<DD><B>4.</B>&nbsp;&nbsp;Add the line <TT>path[boot]=/lib/modules/&#146;uname -r&#146;/boot</TT> as the next line of <TT>/etc/conf.modules</TT>. If you want to make sure that you have typed this correctly before saving your changes, execute the command <TT>echo /lib/modules/&#146;uname -r&#146;/boot</TT> on another virtual terminal or <TT>xterm</TT>. The output should have your current kernel version in place of the <TT>&#145;uname -r&#146;</TT>.

<DD><B>5.</B>&nbsp;&nbsp;Restart <TT>kerneld</TT>. There are lots of ways to do this, but the command <TT>/etc/rc.d/init.d/kerneld restart</TT> works adequately.

</DL>

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="575-578.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="581-583.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -