Docs/SysAdmin/CLI/SerialConsole

From Mandriva Community Wiki

Jump to: navigation, search
Serial Console Howto

It is sometimes useful to log the kernel messages (kernel panics etc.) for debugging purposes. A configuration that allows the use of a serial console is documented here.

The configuration described is also useful for fixing or cleanly shutting down the system when the main console goes dead. It is not quite as convenient as a network connection, but is a good alternative nonetheless.

Contents


[edit] How to setup a serial console

If you are doing kernel development, you want to have a test computer and a serial console to capture Oops messages. The easiest way to setup a serial console is described below.

NOTE: This document assumes the use of COM1. When using another serial port, be careful to change all relevant configuration information. For example, to use COM2 instead of COM1, as appropriate, change "S0" to "S1" and "tts/0" to "tts/1" in the example texts.

[edit] Things that you need to do on the (Oopsing) test machine:

[edit] Machine that fails to install:

Boot from the installation CD, and when prompted with "Enter" to continue or "F1" for options, press "F1", and type:

linux YourOptions console=ttyS0,9600n8

[edit] Preinstalled machine:

  • For Lilo, add to your /etc/lilo.conf file:

    serial=0,9600n8:

    • This allows you to get a lilo choice over a serial console.:

    serial=1,9600n8:

    • If you want to use ttyS1, change ttyS0 on the next line too.:

    append="console=tty0 console=ttyS0,9600:

    • To get console messages to appear in both serial & normal console the one that you put second is the one that get the init messages of [OK], [FAILED] and friends.
  • For grub, add the following in the header of /boot/grub/menu.lst:

    serial --unit=0 --port=0x3f8 --speed=9600 --word=8 --parity=no --stop=1
    terminal console serial

    • Where --unit=x, such that x = 0 for COM1, 1 for COM2, etc.
    • Either --unit=x or --port=y are needed; both are not required.
    • There is no need for --speed to be this slow as 57600 works fine.
    • The order of console and serial determine the default if a user does not type anything on either console prior to the bootloader timeout; the default is listed first.
  • Add the following to /etc/inittab:

    S0:12345:respawn:/sbin/agetty ttyS0 9600 vt100

    -or-

    S0:12345:respawn:/sbin/getty ttyS0 DT9600 ansi

    • Someone has previously noted that mingetty was used on a Corporate 2.1.1, but mingetty documentation states that is does not support serial consoles so your mileage may vary.
    • mgetty may also be a possibility.
  • Add the following to /etc/securetty (to be able to log as root at the serial console):

    ttyS0
    tts/0
  • The serial console may be started without rebooting. To do so, use the following command:

    telinit Q

[edit] The required cable hookup

  • A full null modem cable is required; a three-wire cable will not work.

[edit] Things that you need to do on the capturing machine:

[edit] On a Linux box

[edit] Minicom installation/configuration

# urpmi minicom

If you have french locals like me, minicom has unusable online help/menus because of the terrible french charset we have! The solution is to edit /etc/profile.d/alias.sh and append the following line:

alias minicom="LC_ALL=C minicom"


If you wish to use minicom as a user instead of root, key in (as root):

mkdir /var/lock/minicom
chmod 1777 /var/lock/minicom

run (as root) :

minicom -s
  • Go in the serial port setup menu.
  • Configure ttyS0 with 9600 8N1
  • Set Hardware Flow Control and Software Flow Control to what is set on the bios of the test machine (both to "off" if you don't know).
  • select for the Lockfile Location : /var/lock/minicom
  • Exit from the serial port setup menu, and save setup as dfl
  • Exit from Minicom.
  • check that users have the rights to access /dev/ttyS0

[edit] Minicom usage:

As normal user, run:

$ minicom

In minicom do the following key sequence : ctrl A L (and select the file name to record the kernel messages).

And you should be able to get it done.

Do the following key sequence to end minicom:

ctrl A X

[edit] screen usage:

Run (as root):

$ screen /dev/ttyS0

[edit] cat usage:

Run (as root):

$ cat /dev/ttyS0 > /path/to/output.txt

[edit] On a Microsoft system

  • "HyperTerminal" and "TeraTerm" both work well.

[edit] Bootup and beyond

  • With GRUB:
    • On each configured serial line or console, the bootloader will prompt for keyboard input. The boot menu will be presented to the location from which keyboard input is received first.
  • All bootloaders:
    • Bear in mind that if a graphical login is configured, it appears much earlier than either a console or a serial login prompt.
  • Simple logging:
    • Once logged in on a serial console, it is very simple to watch logs with a command like:

      tail -f /var/log/syslog
Personal tools