Comments on Setting up a serial console
Setting up a serial console This tutorial will show you how to set up a serial console on a Linux system, and connect to it via a null modem cable. This is quite useful if your Linux server is in a headless configuration (no keyboard or monitor), as it allows you to easily get a console on the system if there are any problems with it (especially network problems, when SSH is not available). In the end, the GRUB menu will appear over the serial link, as will the bootup messages (output when booting the system). I'm using Debian Etch on the server and Ubuntu Edgy on my client, although this should work on any Linux distribution.
7 Comment(s)
Comments
1. You can easily use faster baud rates like 57600.
2. vt102 is the best terminal emulation offered by the kernel. For more information - "man console_codes". For a comparison of various terminals see the Kermit 95 Terminal Types list.
3. On Ubuntu Edgy Eft (6.10) or later, Upstart is used instead of init. To configure ttyS0, create a new entry in /etc/event.d by copying one of the existing tty# entries and modifying it. Example ttyS0:
------------------------------------------------------
# ttyS0 - getty
#
# This service maintains a getty on ttyS0 from the point the system is
# started
start on runlevel-2
start on runlevel-3
start on runlevel-4
start on runlevel-5
stop on shutdown
respawn /sbin/getty -L 38400 ttyS0 vt102
------------------------------------------------------
4. On Ubuntu, for a non-root user to access ttyS0 they must be a member of the dialout group.
5. Some versions of Grub (0.95, 0.97) on Edgy Eft have broken serial support. See bug #32904. This appears to be fixed in Feisty Fawn (7.04) Herd 5.
6. Other options for serial terminals are minicom, cu, and c-kermit:
apt-get install minicom
man minicom
minicom -s # Initial setup. Set port as required and erase modem init and reset strings.
minicom # Normal startup. You are connected immediately. Enter Ctrl-A followed by "Z" for help.
apt-get install cu
man cu
cu -lttyS0
Enter "~.~." to disconnect.
apt-get install ckermit
man kermit
kermit -l /dev/ttyS0 -b 38400 -8
Enter "?" for a list of commands. Enter "connect" to connect to port. Enter a Ctrl-\ and then a "C" to return to local.
7. You can run Midnight Commander through a terminal. Minicom doesn't support graphic characters well so using cu or kermit is recommended.
apt-get install mc
mc
mc -c # if you want color (overrides MC's default behavior which is based on target system's TERM variable)
One of the limitations of the vt100/vt102 terminals is the lack of support for function keys other than F1-F4 and some navigation keys. In MC you can use Esc # where # is 1-9,0 representing the F1-F10 menu keys.
Other references:
http://www.linuxselfhelp.com/HOWTO/Text-Terminal-HOWTO-9.html
http://tldp.org/HOWTO/html_single/Text-Terminal-HOWTO/
http://www.gnu.org/software/grub/manual/grub.html#Serial-terminal
Also see serial-console.txt in the kernel documentation.
First, thanks for posting this really helpful information. I have what I hope is a simple question. This post sets up the console to emulate a VT102 or VT100 terminal. If I'm using a printing console (a traditional printing tty) then what emulation would I use? I found a reference in "man getty" that seems to suggest that the line /sbin/getty 9600 ttys1 would do the trick. (serial port 1 at 9600 baud and no terminal emulation.) Before I head down that road I wondered if I was on the right path.
Super tutorial!
In case you do not have either minicom, or a full-blown X with GTkTerm, you can use the terminal based 'screen' application.
Screen can use a serial port as well, you simply hook up you laptop with either a RS-232 or an USB-to-RS-232 and start your session with:
screen /dev/ttyS0 38400 , or in the USB dongle case : screen /dev/ttyUSB0 38400
Thankyou - just what I was looking for.
Thanks so much for the tutorial. I hope you don't mind revisiting this. I'd like to create a small system that uses a printing terminal instead of a VT type terminal or emulator. I'd also like to use Ubuntu 14.04.
Are there any changes that I should be aware of in your tuturial?
What terminal type should I use for the printing terminal using 9600 baud Even parity and 1 stop bit?
Thanks for your help. This is a demonstration project for a history class that I'm teaching. I'd like to make sure that it goes according to plan.
David
Hi, thank ypu for your great post.
i've a Q. I have a xen with ubuntu host, which i want use it's serial console with three times hitting CTRL-a in it. (as xl dmesg output shows), but after installing screen, entering it by 'screen /dev/ttyS0/ 57600', when pressing three times of CTRL-a, i can not see Xen serial output.
would you please tell me what can i do? Does it need any change in grub2 file of xen host? if so, How?
Thanks a lot.