特殊:Badtitle/NS100:SerialConsoleHowto:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
(未显示2个用户的5个中间版本) | |||
第1行: | 第1行: | ||
{{From|https://help.ubuntu.com/community/SerialConsoleHowto}} | {{From|https://help.ubuntu.com/community/SerialConsoleHowto}} | ||
{{Languages|UbuntuHelp:SerialConsoleHowto}} | {{Languages|UbuntuHelp:SerialConsoleHowto}} | ||
This document presents (almost) the minimum amount of work required to enable a serial console login on an Ubuntu 6.06 | This document presents (almost) the minimum amount of work required to enable a serial console login on an Ubuntu 6.06 and later versions. (Minor changes have been added to improve performance.) Both server and client settings are included. | ||
This procedure was developed using the Remote Serial Console HOWTO (see "External links" below), and adapted to apply specifically to Ubuntu. The reader is referred to this document for any issues arising from using this HOWTO. | |||
This procedure was developed using the Remote Serial Console HOWTO ( | |||
==== Assumptions ==== | ==== Assumptions ==== | ||
* You have enabled the serial console in your BIOS. | * You have enabled the serial console in your BIOS.<<FootNote(This is only needed if you plan to use serial console to enter BIOS configuration utility or observe early startup messages even before GRUB starts. Note, that in some cas1es it may interfere with GRUB settings described below. If you're sure you've configured GRUB correctly, but the serial menu does not appear, try '''disabling''' serial console support in BIOS.)>> | ||
* The serial connection is being made at 115200 baud 8n1, on | * The serial connection is being made at 115200 baud 8n1, on first serial port, called /dev/ttyS0 in linux (9600 8n1 is the default fall back if your hardware does not support 115200 baud) | ||
* You are comfortable editing critical system files such as /etc/inittab, /boot/grub/menu.lst | * You are comfortable editing critical system files such as /etc/inittab, /boot/grub/menu.lst | ||
* You are using a serial (null modem) cable. It is also possible to use a USB to Serial adaptor, but the tty* must be changed to reflect your hardware. | * You are using a serial (null modem) cable. It is also possible to use a USB to Serial adaptor, but the tty* must be changed to reflect your hardware. | ||
If you want to use a standard Ethernet/RJ-45 cable for serial connection you can buy a couple of Serial to Cat 5 adapters or [http://www.lammertbies.nl/comm/cable/yost-serial-rj45.html make one yourself]. | |||
=== Server Setup === | |||
==== Configuring the console login process ==== | |||
This section details how to configure the 'getty' process to enable a login via the console port. You need to configure either an Upstart system or the older inittab, depending on Ubuntu version you are using. | |||
Configuring upstart '''(Karmic and newer)''' | |||
1) Paste the following into /etc/init/ttyS0.conf | |||
<pre><nowiki> | |||
# ttyS0 - getty | |||
# | |||
# This service maintains a getty on ttyS0 from the point the system is | |||
# started until it is shut down again. | |||
start on stopped rc RUNLEVEL=[2345] | |||
stop on runlevel [!2345] | |||
respawn | |||
exec /sbin/getty -L 115200 ttyS0 vt102 | |||
</nowiki></pre> | |||
2) Ask upstart to start the getty | |||
<pre><nowiki> | |||
sudo start ttyS0 | |||
</nowiki></pre> | |||
Configuring upstart '''(Edgy/Feisty/Jaunty)''' | |||
Paste the following into /etc/event.d/ttyS0 | |||
<pre><nowiki> | |||
# ttyS0 - getty | |||
# | |||
# This service maintains a getty on ttyS0 from the point the system is | |||
# started until it is shut down again. | |||
start on runlevel 2 | |||
start on runlevel 3 | |||
start on runlevel 4 | |||
start on runlevel 5 | |||
stop on runlevel 0 | |||
stop on runlevel 1 | |||
stop on runlevel 6 | |||
respawn | |||
exec /sbin/getty 115200 ttyS0 | |||
</nowiki></pre> | |||
Configuring inittab '''(only Dapper and older !)''' | |||
1) Edit /etc/inittab | 1) Edit /etc/inittab | ||
<pre><nowiki> | <pre><nowiki> | ||
sudo vi /etc/inittab | sudo vi /etc/inittab | ||
</nowiki></pre> | </nowiki></pre> | ||
2) Change the following line: | 2) Change the following line: | ||
<pre><nowiki> | <pre><nowiki> | ||
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100 | |||
</nowiki></pre> | </nowiki></pre> | ||
to: | to: | ||
<pre><nowiki> | <pre><nowiki> | ||
T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100 | T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100 | ||
</nowiki></pre> | </nowiki></pre> | ||
3) Restart init: | 3) Restart init: | ||
<pre><nowiki> | <pre><nowiki> | ||
sudo /sbin/telinit q | sudo /sbin/telinit q | ||
</nowiki></pre> | </nowiki></pre> | ||
At this point, a new login prompt should appear on the output of the serial console. | At this point, a new login prompt should appear on the output of the serial console. | ||
==== Configuring grub ==== | ==== Configuring grub ==== | ||
This section details how to get grub talking via the serial port. | This section details how to get grub talking via the serial port. | ||
This section is optional if the user does not want grub interaction via the serial console port. | This section is optional if the user does not want grub interaction via the serial console port. | ||
Configuring '''(Karmic and newer)''' | |||
1) Edit /etc/default/grub | |||
<pre><nowiki> | |||
# If you change this file, run 'update-grub' afterwards to update | |||
# /boot/grub/grub.cfg. | |||
GRUB_DEFAULT=0 | |||
GRUB_TIMEOUT=1 | |||
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` | |||
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8" | |||
# Uncomment to disable graphical terminal (grub-pc only) | |||
GRUB_TERMINAL=serial | |||
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1" | |||
# The resolution used on graphical terminal | |||
# note that you can use only modes which your graphic card supports via VBE | |||
# you can see them in real GRUB with the command `vbeinfo' | |||
#GRUB_GFXMODE=640x480 | |||
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux | |||
#GRUB_DISABLE_LINUX_UUID=true | |||
</nowiki></pre> | |||
2) update grub | |||
<code><nowiki> update-grub</nowiki></code> | |||
Configuring grub '''(Edgy/Feisty/Jaunty)''' | |||
1) Edit /boot/grub/menu.lst: | 1) Edit /boot/grub/menu.lst: | ||
<pre><nowiki> | <pre><nowiki> | ||
vi /boot/grub/menu.lst | vi /boot/grub/menu.lst | ||
</nowiki></pre> | </nowiki></pre> | ||
2) Add the following lines to the top of the file: | 2) Add the following lines to the top of the file: | ||
<pre><nowiki> | <pre><nowiki> | ||
# Enable console output via the serial port. unit 0 is /dev/ttyS0, unit 1 is /dev/ttyS1... | |||
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 | serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 | ||
terminal --timeout=15 serial console | terminal --timeout=15 serial console | ||
</nowiki></pre> | </nowiki></pre> | ||
3) When you next reboot, the output from grub will go to the normal console '''unless''' input is received from the serial port. Whichever receives input first becomes the default console. This gives you the best of both worlds. | 3) When you next reboot, the output from grub will go to the normal console '''unless''' input is received from the serial port. Whichever receives input first becomes the default console. This gives you the best of both worlds. | ||
==== Configuring the kernel boot parameters ==== | ==== Configuring the kernel boot parameters ==== | ||
This section details how to configure the kernel boot parameters to get boot information through the console port. | This section details how to configure the kernel boot parameters to get boot information through the console port. | ||
This section is optional if the user does not want the kernel boot messages to appear on the serial console port. | This section is optional if the user does not want the kernel boot messages to appear on the serial console port. | ||
The following procedure can be carried out by modifying the 'kernel' line in grub prior to committing the changes directly to the /boot/grub/menu.lst file. | The following procedure can be carried out by modifying the 'kernel' line in grub prior to committing the changes directly to the /boot/grub/menu.lst file. | ||
1) Edit /boot/grub/menu.lst: | 1) Edit /boot/grub/menu.lst: | ||
<pre><nowiki> | <pre><nowiki> | ||
sudo vi /boot/grub/menu.lst | sudo vi /boot/grub/menu.lst | ||
</nowiki></pre> | </nowiki></pre> | ||
2) Modify the kernel line for the image you want to boot using the serial console on. In this case, I'm setting up the default 2.6.10-5.386 kernel to use the serial console line. Change: | 2) Modify the kernel line for the image you want to boot using the serial console on. In this case, I'm setting up the default 2.6.10-5.386 kernel to use the serial console line. Change: | ||
<pre><nowiki> | <pre><nowiki> | ||
title Ubuntu, kernel 2.6.10-5-386 | title Ubuntu, kernel 2.6.10-5-386 | ||
第87行: | 第126行: | ||
boot | boot | ||
</nowiki></pre> | </nowiki></pre> | ||
to: | to: | ||
<pre><nowiki> | <pre><nowiki> | ||
title Ubuntu, kernel 2.6.10-5-386 | title Ubuntu, kernel 2.6.10-5-386 | ||
第98行: | 第135行: | ||
boot | boot | ||
</nowiki></pre> | </nowiki></pre> | ||
Note two "console=" kernel options. You can specify this option several times. All devices, mentioned in it will receive kernel messages (those, generated by printk() and seen by dmesg). However, stdin/stdout/stderr of <code><nowiki>/sbin/init</nowiki></code> process will be set to the last device only, therefore '''only the last device''' will show startup messages and act as a console in single-user mode. | |||
3) Reboot into this kernel. Output from the boot process should be sent via the serial console line. | 3) Reboot into this kernel. Output from the boot process should be sent via the serial console line. | ||
=== Client Setup === | === Client Setup === | ||
1) Ensure you have a read/write permissions on /dev/ttyS0. | |||
1) Install minicom | <pre><nowiki> | ||
$ ls -l /dev/ttyS0 | |||
crw-rw---- 1 root dialout 4, 64 2007-12-20 13:56 /dev/ttyS0 | |||
$ id -Gn |grep dialout | |||
</nowiki></pre> | |||
if the last command didn't show an output add yourself to <code><nowiki>dialout</nowiki></code> group and logout/login: | |||
<pre><nowiki> | |||
sudo adduser $USER dialout | |||
</nowiki></pre> | |||
Alternatively, you can always run minicom through sudo, but it's not recommended. | |||
2) Install minicom | |||
<pre><nowiki> | <pre><nowiki> | ||
sudo apt-get install minicom | sudo apt-get install minicom | ||
</nowiki></pre> | </nowiki></pre> | ||
3) Configure minicom. | |||
<pre><nowiki> | <pre><nowiki> | ||
minicom -s | |||
</nowiki></pre> | </nowiki></pre> | ||
4) Configure client serial port settings: In Serial port setup, set the following options | |||
<pre><nowiki> | <pre><nowiki> | ||
A - Serial device: /dev/ttyS0 | A - Serial device: /dev/ttyS0 | ||
E - Bps/Par/Bits: 115200 8N1 | E - Bps/Par/Bits: 115200 8N1 | ||
</nowiki></pre> | </nowiki></pre> | ||
4b) Using 7.10 on the server, I needed to set the following on the client: | |||
<pre><nowiki> | |||
F - Hardware Flow Control : No | |||
</nowiki></pre> | |||
My 7.10 client and Windows' HyperTerminal both defaulted to Yes; until I changed this client -> server communication did not work. | |||
5) Configure Initialization string: In Modem and dialing clear the init | |||
<pre><nowiki> | <pre><nowiki> | ||
A - Init string ..... | A - Init string ..... | ||
</nowiki></pre> | </nowiki></pre> | ||
6) Save setup as dfl | |||
7) You might need to press enter several times to get the connection running. | |||
8) To log on in the future, run | |||
<pre><nowiki> | <pre><nowiki> | ||
minicom | |||
</nowiki></pre> | </nowiki></pre> | ||
and press enter several times if it does not come up on start up. | and press enter several times if it does not come up on start up. | ||
=== External links === | |||
* [http://www.faqs.org/docs/Linux-HOWTO/Remote-Serial-Console-HOWTO.html Serial Console Howto] | |||
[[ | * [http://www.rajeevnet.com/linux/grub_serial_console.html Setup Serial Console with GRUB bootloader] | ||
* [http://www.cpqlinux.com/serialconsole.html Serial Console] | |||
[[category:UbuntuHelp]] | [[category:UbuntuHelp]] |
2009年11月17日 (二) 20:34的最新版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/SerialConsoleHowto }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/af | • {{#if: UbuntuHelp:SerialConsoleHowto|Afrikaans| [[::SerialConsoleHowto/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/ar | • {{#if: UbuntuHelp:SerialConsoleHowto|العربية| [[::SerialConsoleHowto/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/az | • {{#if: UbuntuHelp:SerialConsoleHowto|azərbaycanca| [[::SerialConsoleHowto/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/bcc | • {{#if: UbuntuHelp:SerialConsoleHowto|جهلسری بلوچی| [[::SerialConsoleHowto/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/bg | • {{#if: UbuntuHelp:SerialConsoleHowto|български| [[::SerialConsoleHowto/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/br | • {{#if: UbuntuHelp:SerialConsoleHowto|brezhoneg| [[::SerialConsoleHowto/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/ca | • {{#if: UbuntuHelp:SerialConsoleHowto|català| [[::SerialConsoleHowto/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/cs | • {{#if: UbuntuHelp:SerialConsoleHowto|čeština| [[::SerialConsoleHowto/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/de | • {{#if: UbuntuHelp:SerialConsoleHowto|Deutsch| [[::SerialConsoleHowto/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/el | • {{#if: UbuntuHelp:SerialConsoleHowto|Ελληνικά| [[::SerialConsoleHowto/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/es | • {{#if: UbuntuHelp:SerialConsoleHowto|español| [[::SerialConsoleHowto/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/fa | • {{#if: UbuntuHelp:SerialConsoleHowto|فارسی| [[::SerialConsoleHowto/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/fi | • {{#if: UbuntuHelp:SerialConsoleHowto|suomi| [[::SerialConsoleHowto/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/fr | • {{#if: UbuntuHelp:SerialConsoleHowto|français| [[::SerialConsoleHowto/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/gu | • {{#if: UbuntuHelp:SerialConsoleHowto|ગુજરાતી| [[::SerialConsoleHowto/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/he | • {{#if: UbuntuHelp:SerialConsoleHowto|עברית| [[::SerialConsoleHowto/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/hu | • {{#if: UbuntuHelp:SerialConsoleHowto|magyar| [[::SerialConsoleHowto/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/id | • {{#if: UbuntuHelp:SerialConsoleHowto|Bahasa Indonesia| [[::SerialConsoleHowto/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/it | • {{#if: UbuntuHelp:SerialConsoleHowto|italiano| [[::SerialConsoleHowto/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/ja | • {{#if: UbuntuHelp:SerialConsoleHowto|日本語| [[::SerialConsoleHowto/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/ko | • {{#if: UbuntuHelp:SerialConsoleHowto|한국어| [[::SerialConsoleHowto/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/ksh | • {{#if: UbuntuHelp:SerialConsoleHowto|Ripoarisch| [[::SerialConsoleHowto/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/mr | • {{#if: UbuntuHelp:SerialConsoleHowto|मराठी| [[::SerialConsoleHowto/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/ms | • {{#if: UbuntuHelp:SerialConsoleHowto|Bahasa Melayu| [[::SerialConsoleHowto/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/nl | • {{#if: UbuntuHelp:SerialConsoleHowto|Nederlands| [[::SerialConsoleHowto/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/no | • {{#if: UbuntuHelp:SerialConsoleHowto|norsk| [[::SerialConsoleHowto/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/oc | • {{#if: UbuntuHelp:SerialConsoleHowto|occitan| [[::SerialConsoleHowto/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/pl | • {{#if: UbuntuHelp:SerialConsoleHowto|polski| [[::SerialConsoleHowto/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/pt | • {{#if: UbuntuHelp:SerialConsoleHowto|português| [[::SerialConsoleHowto/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/ro | • {{#if: UbuntuHelp:SerialConsoleHowto|română| [[::SerialConsoleHowto/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/ru | • {{#if: UbuntuHelp:SerialConsoleHowto|русский| [[::SerialConsoleHowto/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/si | • {{#if: UbuntuHelp:SerialConsoleHowto|සිංහල| [[::SerialConsoleHowto/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/sq | • {{#if: UbuntuHelp:SerialConsoleHowto|shqip| [[::SerialConsoleHowto/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/sr | • {{#if: UbuntuHelp:SerialConsoleHowto|српски / srpski| [[::SerialConsoleHowto/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/sv | • {{#if: UbuntuHelp:SerialConsoleHowto|svenska| [[::SerialConsoleHowto/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/th | • {{#if: UbuntuHelp:SerialConsoleHowto|ไทย| [[::SerialConsoleHowto/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/tr | • {{#if: UbuntuHelp:SerialConsoleHowto|Türkçe| [[::SerialConsoleHowto/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/vi | • {{#if: UbuntuHelp:SerialConsoleHowto|Tiếng Việt| [[::SerialConsoleHowto/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/yue | • {{#if: UbuntuHelp:SerialConsoleHowto|粵語| [[::SerialConsoleHowto/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/zh | • {{#if: UbuntuHelp:SerialConsoleHowto|中文| [[::SerialConsoleHowto/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/zh-hans | • {{#if: UbuntuHelp:SerialConsoleHowto|中文(简体)| [[::SerialConsoleHowto/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:SerialConsoleHowto | UbuntuHelp:SerialConsoleHowto | {{#if: | :}}SerialConsoleHowto}}/zh-hant | • {{#if: UbuntuHelp:SerialConsoleHowto|中文(繁體)| [[::SerialConsoleHowto/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:SerialConsoleHowto|:SerialConsoleHowto|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :SerialConsoleHowto/zh | | {{#ifexist: SerialConsoleHowto/zh | | {{#ifeq: {{#titleparts:SerialConsoleHowto|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:SerialConsoleHowto|1|-1|}} | zh | | }}
This document presents (almost) the minimum amount of work required to enable a serial console login on an Ubuntu 6.06 and later versions. (Minor changes have been added to improve performance.) Both server and client settings are included. This procedure was developed using the Remote Serial Console HOWTO (see "External links" below), and adapted to apply specifically to Ubuntu. The reader is referred to this document for any issues arising from using this HOWTO.
Assumptions
- You have enabled the serial console in your BIOS.<<FootNote(This is only needed if you plan to use serial console to enter BIOS configuration utility or observe early startup messages even before GRUB starts. Note, that in some cas1es it may interfere with GRUB settings described below. If you're sure you've configured GRUB correctly, but the serial menu does not appear, try disabling serial console support in BIOS.)>>
- The serial connection is being made at 115200 baud 8n1, on first serial port, called /dev/ttyS0 in linux (9600 8n1 is the default fall back if your hardware does not support 115200 baud)
- You are comfortable editing critical system files such as /etc/inittab, /boot/grub/menu.lst
- You are using a serial (null modem) cable. It is also possible to use a USB to Serial adaptor, but the tty* must be changed to reflect your hardware.
If you want to use a standard Ethernet/RJ-45 cable for serial connection you can buy a couple of Serial to Cat 5 adapters or make one yourself.
Server Setup
Configuring the console login process
This section details how to configure the 'getty' process to enable a login via the console port. You need to configure either an Upstart system or the older inittab, depending on Ubuntu version you are using. Configuring upstart (Karmic and newer) 1) Paste the following into /etc/init/ttyS0.conf
# ttyS0 - getty # # This service maintains a getty on ttyS0 from the point the system is # started until it is shut down again. start on stopped rc RUNLEVEL=[2345] stop on runlevel [!2345] respawn exec /sbin/getty -L 115200 ttyS0 vt102
2) Ask upstart to start the getty
sudo start ttyS0
Configuring upstart (Edgy/Feisty/Jaunty) Paste the following into /etc/event.d/ttyS0
# ttyS0 - getty # # This service maintains a getty on ttyS0 from the point the system is # started until it is shut down again. start on runlevel 2 start on runlevel 3 start on runlevel 4 start on runlevel 5 stop on runlevel 0 stop on runlevel 1 stop on runlevel 6 respawn exec /sbin/getty 115200 ttyS0
Configuring inittab (only Dapper and older !) 1) Edit /etc/inittab
sudo vi /etc/inittab
2) Change the following line:
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
to:
T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100
3) Restart init:
sudo /sbin/telinit q
At this point, a new login prompt should appear on the output of the serial console.
Configuring grub
This section details how to get grub talking via the serial port. This section is optional if the user does not want grub interaction via the serial console port. Configuring (Karmic and newer) 1) Edit /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. GRUB_DEFAULT=0 GRUB_TIMEOUT=1 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8" # Uncomment to disable graphical terminal (grub-pc only) GRUB_TERMINAL=serial GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1" # The resolution used on graphical terminal # note that you can use only modes which your graphic card supports via VBE # you can see them in real GRUB with the command `vbeinfo' #GRUB_GFXMODE=640x480 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux #GRUB_DISABLE_LINUX_UUID=true
2) update grub
update-grub
Configuring grub (Edgy/Feisty/Jaunty)
1) Edit /boot/grub/menu.lst:
vi /boot/grub/menu.lst
2) Add the following lines to the top of the file:
# Enable console output via the serial port. unit 0 is /dev/ttyS0, unit 1 is /dev/ttyS1... serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 terminal --timeout=15 serial console
3) When you next reboot, the output from grub will go to the normal console unless input is received from the serial port. Whichever receives input first becomes the default console. This gives you the best of both worlds.
Configuring the kernel boot parameters
This section details how to configure the kernel boot parameters to get boot information through the console port. This section is optional if the user does not want the kernel boot messages to appear on the serial console port. The following procedure can be carried out by modifying the 'kernel' line in grub prior to committing the changes directly to the /boot/grub/menu.lst file. 1) Edit /boot/grub/menu.lst:
sudo vi /boot/grub/menu.lst
2) Modify the kernel line for the image you want to boot using the serial console on. In this case, I'm setting up the default 2.6.10-5.386 kernel to use the serial console line. Change:
title Ubuntu, kernel 2.6.10-5-386 root (hd0,0) kernel /boot/vmlinuz-2.6.10-5-386 root=/dev/hda1 ro quiet splash initrd /boot/initrd.img-2.6.10-5-386 savedefault boot
to:
title Ubuntu, kernel 2.6.10-5-386 root (hd0,0) kernel /boot/vmlinuz-2.6.10-5-386 root=/dev/hda1 ro quiet splash console=tty0 console=ttyS0,115200n8 initrd /boot/initrd.img-2.6.10-5-386 savedefault boot
Note two "console=" kernel options. You can specify this option several times. All devices, mentioned in it will receive kernel messages (those, generated by printk() and seen by dmesg). However, stdin/stdout/stderr of /sbin/init
process will be set to the last device only, therefore only the last device will show startup messages and act as a console in single-user mode.
3) Reboot into this kernel. Output from the boot process should be sent via the serial console line.
Client Setup
1) Ensure you have a read/write permissions on /dev/ttyS0.
$ ls -l /dev/ttyS0 crw-rw---- 1 root dialout 4, 64 2007-12-20 13:56 /dev/ttyS0 $ id -Gn |grep dialout
if the last command didn't show an output add yourself to dialout
group and logout/login:
sudo adduser $USER dialout
Alternatively, you can always run minicom through sudo, but it's not recommended. 2) Install minicom
sudo apt-get install minicom
3) Configure minicom.
minicom -s
4) Configure client serial port settings: In Serial port setup, set the following options
A - Serial device: /dev/ttyS0 E - Bps/Par/Bits: 115200 8N1
4b) Using 7.10 on the server, I needed to set the following on the client:
F - Hardware Flow Control : No
My 7.10 client and Windows' HyperTerminal both defaulted to Yes; until I changed this client -> server communication did not work. 5) Configure Initialization string: In Modem and dialing clear the init
A - Init string .....
6) Save setup as dfl 7) You might need to press enter several times to get the connection running. 8) To log on in the future, run
minicom
and press enter several times if it does not come up on start up.