Linux Serial Console

Configuring Grub

These instructions are for COM1. If a different serial port is used (e.g. COM4 on Krang), then change --unit=XX to the appropriate zero-based index (e.g. COM4 == --unit=3) and change ttyS0 to ttyS# where # is the same zero-based index.

GRUB (pre-v2)

Add the following two lines to the top of your /boot/grub/menu.list file:


serial --unit=0 --speed=38400 --word=8 --parity=no --stop=1
terminal --timeout=10 serial console

This will cause grub to print a message on both the serial (COM1) and vga consoles until a key is pressed on either to activate that console. It will timeout after 10 seconds.

GRUB v2

Add the following two lines to your /etc/default/grub file:


GRUB_TERMINAL_INPUT=serial
GRUB_TERMINAL_OUTPUT=serial
GRUB_SERIAL_COMMAND="serial --timeout=10 --unit=0 --speed=38400 --word=8 --parity=no --stop=1"

This will cause grub to print a message on the serial until a key is pressed on either to activate that console. It will timeout after 10 seconds. Unfortunately, unlike the configuration for legacy GRUB, GRUB2 currently [2011-09-17] does not support enabling both the console and the terminal at the same time through the grub-mkconfig scripts.

Configuring Kernel

Add the following to the end of the kernel commandline:


console=tty0 console=ttyS0,38400

GRUB2

In GRUB2, this can be appended to each automatically configured linux kernel by putting in /etc/default/grub the following:

GRUB_CMDLINE_LINUX="console=tty1 console=ttyS0,38400"

If COM1 is not used, then change ttyS0 the appropriate COM port.

Configuring Linux Gettys

Using Upstart (Ubuntu)

Create file /etc/init/ttyS0.conf with the following:


start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]

respawn
exec /sbin/getty -L 38400 ttyS3 xterm

If you want to use a serial port other than ttyS0, just substitute that name in.

Then do a sudo service ttyS0 start to start the terminal.

Using init (Debian)

Add the following line to /etc/inittab:


T0:2345:respawn:/sbin/getty -L ttyS0 38400 xterm

Then do a sudo telinit q to make init reread it's config file.

Client Login

To login from a client computer, you need your usual terminal emulator and some type of connection program:

  • cu
  • kermit
  • minicom
  • hyperterminal (MS Windows terminal emulator + modem dialer)

Using cu

To connect using the the previously described configuration, do a cu -lttyS0 --parity=none -s38400 --nostop. If the serial port you are using on the client is not ttyS0, replace it with the proper one. Note that USB serial adapters in linux are usually named ttyUSB0, ttyUSB1, etc.

External Links