User Tools

Site Tools


howtos:serial_console

Serial Console

This guide is for Ubuntu Hardy Heron or other systems using upstart instead of sysvinit. If you're unsure about what type of system you're using just look for /etc/inittab. If it's there (and you didn't put it there) then it's a sysvinit system. If not then proceed.

getty

Usually getty is installed default (getty is the daemon we're going to use for connecting through the serial console) but just to be sure run:

domingo@domingo-desktop:~$ getty
Usage: getty [-8hiLmUw] [-l login_program] [-t timeout] [-I initstring] [-H login_host] baud_rate,... line [termtype]
or [-hiLmw] [-l login_program] [-t timeout] [-I initstring] [-H login_host] line baud_rate,... [termtype]

Spawning getty

To get getty running on the system we need the file /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 -L 9600 ttyS0 vt102

This file setup a console server on the serial interface ttyS0 with the baud speed 9600 and terminal type vt102. You can select an other I just seem to able to remember this one better (I usually only use it when something is terribly wrong and thing need to be fixed fast) and the speed is fine for me.

To invoke the settings without reboot run:

sudo initctl start ttyS0

If no errors occur just run a ps to check if the daemon has started correctly (or just attach a cable):

root@server:~# ps aux|grep 9600
root      8567  0.0  0.0   1716   520 ttyS0    Ss+  18:40   0:00 /sbin/getty -L 9600 ttyS0 vt102
root      9035  0.0  0.0   3004   768 pts/2    R+   19:09   0:00 grep 9600

Quick Setting Up Console

If you just need to put up a quick serial console server (ex. to test the communication ports) you can run the following command:

sudo getty -L 9600 ttyUSB0 vt102

This will make getty listen on the “serial” device called ttyUSB0. In my case this is a usb-to-serial converter as my machine doesn't have a native serial interface. Just change ttyUSB0 to ttyS0 if you have a real serial interface in your machine.

howtos/serial_console.txt · Last modified: 02/12/2018 20:34 by 127.0.0.1