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

📄 serialconsole-setup.html

📁 FreeBSD操作系统的详细使用手册
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<div class="INFORMALTABLE"><a id="AEN29760" name="AEN29760"></a><table border="0" frame="void" class="CALSTABLE"><col /><col /><col /><col /><thead><tr><th>Options in /boot.config</th><th>Console during boot blocks</th><th>Console during boot loader</th><th>Console in kernel</th></tr></thead><tbody><tr><td>nothing</td><td>internal</td><td>internal</td><td>internal</td></tr><tr><td><var class="OPTION">-h</var></td><td>serial</td><td>serial</td><td>serial</td></tr><tr><td><var class="OPTION">-D</var></td><td>serial and internal</td><td>internal</td><td>internal</td></tr><tr><td><var class="OPTION">-Dh</var></td><td>serial and internal</td><td>serial</td><td>serial</td></tr><tr><td><var class="OPTION">-P</var>, keyboard present</td><td>internal</td><td>internal</td><td>internal</td></tr><tr><td><var class="OPTION">-P</var>, keyboard absent</td><td>serial and internal</td><td>serial</td><td>serial</td></tr></tbody></table></div></div><div class="SECT3"><h3 class="SECT3"><a id="AEN29804" name="AEN29804">20.6.4.2 Case 2: You Set the Flags to0x30 for sio0</a></h3><pre class="PROGRAMLISTING">device sio0 at isa? port IO_COM1 flags 0x30 irq 4</pre><div class="INFORMALTABLE"><a id="AEN29807" name="AEN29807"></a><table border="0" frame="void" class="CALSTABLE"><col /><col /><col /><col /><thead><tr><th>Options in /boot.config</th><th>Console during boot blocks</th><th>Console during boot loader</th><th>Console in kernel</th></tr></thead><tbody><tr><td>nothing</td><td>internal</td><td>internal</td><td>serial</td></tr><tr><td><var class="OPTION">-h</var></td><td>serial</td><td>serial</td><td>serial</td></tr><tr><td><var class="OPTION">-D</var></td><td>serial and internal</td><td>internal</td><td>serial</td></tr><tr><td><var class="OPTION">-Dh</var></td><td>serial and internal</td><td>serial</td><td>serial</td></tr><tr><td><var class="OPTION">-P</var>, keyboard present</td><td>internal</td><td>internal</td><td>serial</td></tr><tr><td><var class="OPTION">-P</var>, keyboard absent</td><td>serial and internal</td><td>serial</td><td>serial</td></tr></tbody></table></div></div></div><div class="SECT2"><h2 class="SECT2"><a id="SERIALCONSOLE-TIPS" name="SERIALCONSOLE-TIPS">20.6.5 Tips forthe Serial Console</a></h2><div class="SECT3"><h3 class="SECT3"><a id="AEN29853" name="AEN29853">20.6.5.1 Setting a Faster Serial PortSpeed</a></h3><p>By default, the serial port settings are: 9600 baud, 8 bits, no parity, and 1 stopbit. If you wish to change the speed, you need to recompile at least the boot blocks. Addthe following line to <tt class="FILENAME">/etc/make.conf</tt> and compile new bootblocks:</p><pre class="PROGRAMLISTING">BOOT_COMCONSOLE_SPEED=19200</pre><p>See <a href="serialconsole-setup.html#SERIALCONSOLE-COM2">Section 20.6.5.2</a> fordetailed instructions about building and installing new boot blocks.</p><p>If the serial console is configured in some other way than by booting with <varclass="OPTION">-h</var>, or if the serial console used by the kernel is different fromthe one used by the boot blocks, then you must also add the following option to thekernel configuration file and compile a new kernel:</p><pre class="PROGRAMLISTING">options CONSPEED=19200</pre></div><div class="SECT3"><h3 class="SECT3"><a id="SERIALCONSOLE-COM2" name="SERIALCONSOLE-COM2">20.6.5.2 UsingSerial Port Other Than <tt class="DEVICENAME">sio0</tt> for the Console</a></h3><p>Using a port other than <tt class="DEVICENAME">sio0</tt> as the console requires somerecompiling. If you want to use another serial port for whatever reasons, recompile theboot blocks, the boot loader and the kernel as follows.</p><div class="PROCEDURE"><ol type="1"><li><p>Get the kernel source. (See <a href="cutting-edge.html">Chapter 19</a>)</p></li><li><p>Edit <tt class="FILENAME">/etc/make.conf</tt> and set <varclass="LITERAL">BOOT_COMCONSOLE_PORT</var> to the address of the port you want to use(0x3F8, 0x2F8, 0x3E8 or 0x2E8). Only <tt class="DEVICENAME">sio0</tt> through <ttclass="DEVICENAME">sio3</tt> (<tt class="DEVICENAME">COM1</tt> through <ttclass="DEVICENAME">COM4</tt>) can be used; multiport serial cards will not work. Nointerrupt setting is needed.</p></li><li><p>Create a custom kernel configuration file and add appropriate flags for the serialport you want to use. For example, if you want to make <tt class="DEVICENAME">sio1</tt>(<tt class="DEVICENAME">COM2</tt>) the console:</p><pre class="PROGRAMLISTING">device sio1 at isa? port IO_COM2 flags 0x10 irq 3</pre><p>or</p><pre class="PROGRAMLISTING">device sio1 at isa? port IO_COM2 flags 0x30 irq 3</pre><p>The console flags for the other serial ports should not be set.</p></li><li><p>Recompile and install the boot blocks and the boot loader:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">cd /sys/boot</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">make clean</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">make</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">make install</kbd></pre></li><li><p>Rebuild and install the kernel.</p></li><li><p>Write the boot blocks to the boot disk with <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=disklabel&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">disklabel</span>(8)</span></a> and bootfrom the new kernel.</p></li></ol></div></div><div class="SECT3"><h3 class="SECT3"><a id="SERIALCONSOLE-DDB" name="SERIALCONSOLE-DDB">20.6.5.3 Enteringthe DDB Debugger from the Serial Line</a></h3><p>If you wish to drop into the kernel debugger from the serial console (useful forremote diagnostics, but also dangerous if you generate a spurious BREAK on the serialport!) then you should compile your kernel with the following options:</p><pre class="PROGRAMLISTING">options BREAK_TO_DEBUGGERoptions DDB</pre></div><div class="SECT3"><h3 class="SECT3"><a id="AEN29910" name="AEN29910">20.6.5.4 Getting a Login Prompt on theSerial Console</a></h3><p>While this is not required, you may wish to get a <span class="emphasis"><iclass="EMPHASIS">login</i></span> prompt over the serial line, now that you can see bootmessages and can enter the kernel debugging session through the serial console. Here ishow to do it.</p><p>Open the file <tt class="FILENAME">/etc/ttys</tt> with an editor and locate thelines:</p><pre class="PROGRAMLISTING">ttyd0 "/usr/libexec/getty std.9600" unknown off securettyd1 "/usr/libexec/getty std.9600" unknown off securettyd2 "/usr/libexec/getty std.9600" unknown off securettyd3 "/usr/libexec/getty std.9600" unknown off secure</pre><p><var class="LITERAL">ttyd0</var> through <var class="LITERAL">ttyd3</var> correspondsto <tt class="DEVICENAME">COM1</tt> through <tt class="DEVICENAME">COM4</tt>. Change <varclass="LITERAL">off</var> to <var class="LITERAL">on</var> for the desired port. If youhave changed the speed of the serial port, you need to change <varclass="LITERAL">std.9600</var> to match the current setting, e.g. <varclass="LITERAL">std.19200</var>.</p><p>You may also want to change the terminal type from <var class="LITERAL">unknown</var>to the actual type of your serial terminal.</p><p>After editing the file, you must <tt class="COMMAND">kill -HUP 1</tt> to make thischange take effect.</p></div></div><div class="SECT2"><h2 class="SECT2"><a id="SERIALCONSOLE-LOADER" name="SERIALCONSOLE-LOADER">20.6.6Changing Console from the Boot Loader</a></h2><p>Previous sections described how to set up the serial console by tweaking the bootblock. This section shows that you can specify the console by entering some commands andenvironment variables in the boot loader. As the boot loader is invoked at the thirdstage of the boot process, after the boot block, the settings in the boot loader willoverride the settings in the boot block.</p><div class="SECT3"><h3 class="SECT3"><a id="AEN29933" name="AEN29933">20.6.6.1 Setting Up the SerialConsole</a></h3><p>You can easily specify the boot loader and the kernel to use the serial console bywriting just one line in <tt class="FILENAME">/boot/loader.rc</tt>:</p><pre class="PROGRAMLISTING">set console=comconsole</pre><p>This will take effect regardless of the settings in the boot block discussed in theprevious section.</p><p>You had better put the above line as the first line of <ttclass="FILENAME">/boot/loader.rc</tt> so as to see boot messages on the serial console asearly as possible.</p><p>Likewise, you can specify the internal console as:</p><pre class="PROGRAMLISTING">set console=vidconsole</pre><p>If you do not set the boot loader environment variable <tt class="ENVAR">console</tt>,the boot loader, and subsequently the kernel, will use whichever console indicated by the<var class="OPTION">-h</var> option in the boot block.</p><p>In versions 3.2 or later, you may specify the console in <ttclass="FILENAME">/boot/loader.conf.local</tt> or <ttclass="FILENAME">/boot/loader.conf</tt>, rather than in <ttclass="FILENAME">/boot/loader.rc</tt>. In this method your <ttclass="FILENAME">/boot/loader.rc</tt> should look like:</p><pre class="PROGRAMLISTING">include /boot/loader.4thstart</pre><p>Then, create <tt class="FILENAME">/boot/loader.conf.local</tt> and put the followingline there.</p><pre class="PROGRAMLISTING">console=comconsole</pre><p>or</p><pre class="PROGRAMLISTING">console=vidconsole</pre><p>See <a href="http://www.FreeBSD.org/cgi/man.cgi?query=loader.conf&sektion=5"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">loader.conf</span>(5)</span></a> formore information.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> At the moment, the boot loader has no option equivalent to the <varclass="OPTION">-P</var> option in the boot block, and there is no provision toautomatically select the internal console and the serial console based on the presence ofthe keyboard.</p></blockquote></div></div><div class="SECT3"><h3 class="SECT3"><a id="AEN29964" name="AEN29964">20.6.6.2 Using a Serial Port OtherThan <tt class="DEVICENAME">sio0</tt> for the Console</a></h3><p>You need to recompile the boot loader to use a serial port other than <ttclass="DEVICENAME">sio0</tt> for the serial console. Follow the procedure described in <ahref="serialconsole-setup.html#SERIALCONSOLE-COM2">Section 20.6.5.2</a>.</p></div></div><div class="SECT2"><h2 class="SECT2"><a id="SERIALCONSOLE-CAVEATS" name="SERIALCONSOLE-CAVEATS">20.6.7Caveats</a></h2><p>The idea here is to allow people to set up dedicated servers that require no graphicshardware or attached keyboards. Unfortunately, while most systems will let you bootwithout a keyboard, there are quite a few that will not let you boot without a graphicsadapter. Machines with AMI BIOSes can be configured to boot with no graphics adapterinstalled simply by changing the ``graphics adapter'' setting in the CMOS configurationto ``Not installed.''</p><p>However, many machines do not support this option and will refuse to boot if you haveno display hardware in the system. With these machines, you will have to leave some kindof graphics card plugged in, (even if it is just a junky mono board) although you willnot have to attach a monitor. You might also try installing an AMI BIOS.</p></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="dialout.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="ppp-and-slip.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Dial-out Service</td><td width="34%" align="center" valign="top"><a href="serialcomms.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">PPP and SLIP</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 + -