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

📄 kernelconfig-trouble.html

📁 FreeBSD操作系统的详细使用手册
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>If Something Goes Wrong</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD Handbook" href="index.html" /><link rel="UP" title="Configuring the FreeBSD Kernel" href="kernelconfig.html" /><link rel="PREVIOUS" title="Making Device Nodes" href="kernelconfig-nodes.html" /><link rel="NEXT" title="Printing" href="printing.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD Handbook</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="kernelconfig-nodes.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 8 Configuring the FreeBSDKernel</td><td width="10%" align="right" valign="bottom"><a href="printing.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="KERNELCONFIG-TROUBLE" name="KERNELCONFIG-TROUBLE">8.6 IfSomething Goes Wrong</a></h1><p>There are five categories of trouble that can occur when building a custom kernel.They are:</p><div class="VARIABLELIST"><dl><dt><tt class="COMMAND">config</tt> fails:</dt><dd><p>If the <a href="http://www.FreeBSD.org/cgi/man.cgi?query=config&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">config</span>(8)</span></a> commandfails when you give it your kernel description, you have probably made a simple errorsomewhere. Fortunately, <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=config&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">config</span>(8)</span></a> will printthe line number that it had trouble with, so that you can quickly locate the linecontaining the error. For example, if you see:</p><pre class="SCREEN">config: line 17: syntax error</pre><p>Make sure the keyword is typed correctly by comparing it to the <ttclass="FILENAME">GENERIC</tt> kernel or another reference.</p></dd><dt><tt class="COMMAND">make</tt> fails:</dt><dd><p>If the <tt class="COMMAND">make</tt> command fails, it usually signals an error inyour kernel description which is not severe enough for <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=config&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">config</span>(8)</span></a> to catch.Again, look over your configuration, and if you still cannot resolve the problem, sendmail to the <a href="http://lists.FreeBSD.org/mailman/listinfo/freebsd-questions"target="_top">FreeBSD general questions mailing list</a> with your kernel configuration,and it should be diagnosed quickly.</p></dd><dt>Installing the new kernel fails:</dt><dd><p>If the kernel compiled fine, but failed to install (the <tt class="COMMAND">makeinstall</tt> or <tt class="COMMAND">make installkernel</tt> command failed), the firstthing to check is if your system is running at securelevel 1 or higher (see <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=init&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">init</span>(8)</span></a>). The kernelinstallation tries to remove the immutable flag from your kernel and set the immutableflag on the new one. Since securelevel 1 or higher prevents unsetting the immutable flagfor any files on the system, the kernel installation needs to be performed at securelevel0 or lower.</p><p>The above only applies to FreeBSD 4.X and earlier versions. FreeBSD 5.X, along withlater versions, does not set the immutable flag on the kernel and a failure to install akernel probably indicates a more fundamental problem.</p></dd><dt>The kernel does not boot:<a id="KERNELCONFIG-NOBOOT"name="KERNELCONFIG-NOBOOT"></a></dt><dd><p>If your new kernel does not boot, or fails to recognize your devices, do not panic!Fortunately, FreeBSD has an excellent mechanism for recovering from incompatible kernels.Simply choose the kernel you want to boot from at the FreeBSD boot loader. You can accessthis when the system counts down from 10 at the boot menu. Hit any key except for the <bclass="KEYCAP">Enter</b> key, type <tt class="COMMAND">unload</tt> and then type <ttclass="COMMAND">boot /boot/<var class="REPLACEABLE">kernel.old</var>/kernel</tt>, or thefilename of any other kernel that will boot properly. When reconfiguring a kernel, it isalways a good idea to keep a kernel that is known to work on hand.</p><p>After booting with a good kernel you can check over your configuration file and try tobuild it again. One helpful resource is the <tt class="FILENAME">/var/log/messages</tt>file which records, among other things, all of the kernel messages from every successfulboot. Also, the <a href="http://www.FreeBSD.org/cgi/man.cgi?query=dmesg&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">dmesg</span>(8)</span></a> command willprint the kernel messages from the current boot.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> If you are having trouble building a kernel, make sure to keep a <ttclass="FILENAME">GENERIC</tt>, or some other kernel that is known to work on hand as adifferent name that will not get erased on the next build. You cannot rely on <ttclass="FILENAME">kernel.old</tt> because when installing a new kernel, <ttclass="FILENAME">kernel.old</tt> is overwritten with the last installed kernel which maybe non-functional. Also, as soon as possible, move the working kernel to the proper <ttclass="FILENAME">/boot/kernel</tt> location or commands such as <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=ps&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">ps</span>(1)</span></a> may not workproperly. To do this, simply rename the directory containing the good kernel:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">mv /boot/kernel /boot/kernel.bad</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">mv /boot/<varclass="REPLACEABLE">kernel.good</var> /boot/kernel</kbd></pre><p>For versions of FreeBSD prior to 5.X, the proper command to ``unlock'' the kernel filethat <tt class="COMMAND">make</tt> installs (in order to move another kernel backpermanently) is:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">chflags noschg /kernel</kbd></pre><p>If you find you cannot do this, you are probably running at a <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=securelevel&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">securelevel</span>(8)</span></a> greaterthan zero. Edit <var class="LITERAL">kern_securelevel</var> in <ttclass="FILENAME">/etc/rc.conf</tt> and set it to <var class="LITERAL">-1</var>, thenreboot. You can change it back to its previous setting when you are happy with your newkernel.</p><p>And, if you want to ``lock'' your new kernel into place, or any file for that matter,so that it cannot be moved or tampered with:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">chflags schg /kernel</kbd></pre></blockquote></div></dd><dt>The kernel works, but <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=ps&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">ps</span>(1)</span></a> does not workany more:</dt><dd><p>If you have installed a different version of the kernel from the one that the systemutilities have been built with, for example, a 5.X kernel on a 4.X system, manysystem-status commands like <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=ps&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">ps</span>(1)</span></a> and <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=vmstat&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">vmstat</span>(8)</span></a> will notwork any more. You should <a href="makeworld.html">recompile and install a world</a>built with the same version of the source tree as your kernel. This is one reason it isnot normally a good idea to use a different version of the kernel from the rest of theoperating system.</p></dd></dl></div></div><div class="NAVFOOTER"><hr align="LEFT" width="100%" /><table summary="Footer navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="kernelconfig-nodes.html"accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html"accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="printing.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Making Device Nodes</td><td width="34%" align="center" valign="top"><a href="kernelconfig.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Printing</td></tr></table></div><p align="center"><small>This, and other documents, can be downloaded from <ahref="ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/">ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/</a>.</small></p><p align="center"><small>For questions about FreeBSD, read the <ahref="http://www.FreeBSD.org/docs.html">documentation</a> before contacting &#60;<ahref="mailto:questions@FreeBSD.org">questions@FreeBSD.org</a>&#62;.<br />For questions about this documentation, e-mail &#60;<ahref="mailto:doc@FreeBSD.org">doc@FreeBSD.org</a>&#62;.</small></p></body></html>

⌨️ 快捷键说明

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