Serial Null Modem Bağlantısı

Şuraya atla: kullan, ara

For debugging purposes it is often useful to have a serial connection to a computer. You have several advantages doing that:

  • a real console is available from remote
  • it is possible to use Sysreq calls from another computer
  • Logs may be just logged instead of typed from the screen
  • login to the machine is possible without a local keyboard or a network connection

What you need:

  1. a primary computer that should be observed, called server
  2. a null modem cabel
  3. a second computer that is connected with that cabel, called client
  4. a terminal emulation program

First, connect both computers with the cable.

Server Configurations

Several actions are needed to make use of a serial connection to the server:

Configure the Bootloader GRUB

Disable the graphics in /boot/grub/menu.lst by adding a comment mark in front of the gfxmenu line:

#gfxmenu (hd0,4)/boot/message

To configure the serial port, add the following two lines to the global section of the menu file:

serial --unit=0 --speed=115200
terminal serial console

This will make the bootloader visible on the serial line.

Tell the Kernel about the new console

add a parameter

console=tty0 console=ttyS0,115200

to the commandline of the kernel. You may also add several devices, seperated by a comma. After the next reboot, the kernel will accept the device /dev/ttyS0 as a console.

Enable sysrq on the Server

Change the variable ENABLE_SYSRQ in /etc/sysconfig/sysctl to "yes". This may also be done with the "/etc/sysconfig Editor" in YaST. This variable is checkd at boottime, and sets the value of /proc/sys/kernel/sysrq accordingly.

Add a login Prompt

In the file /etc/inittab, remove the # at the beginning of the line

S0:12345:respawn:/sbin/agetty -L 115200 ttyS0 vt102

This will enable you to login as a normal user. To be able to login as root, you still need to add this device to /etc/securetty. Add the line

ttyS0

in securetty to have this possibility. If you don't want to reboot after this, run the command

telinit q

to reload the configuration file.

Redirect system messages

If you alternatively want to view system messages via serial line instead of getting a login prompt, add the following line to your /etc/syslog.conf instead:

*.* /dev/ttyS0 

Client

On the client side, you basically need a terminal emulation program. A nifty tool for that is screen. If the serial port on the client is /dev/ttyS0, start the connection as follows:

screen /dev/ttyS0 115200

If all was done correctly, a login prompt should appear.

screen has many useful options. By default, you access its commands by typing CTRL-a <letter>. A small help is displayed with CTRL-A ? . Often used features are:

  • CTRL-A H
    start/stop a log on screenlog.0 in the current directory.
  • CTRL-A B
    send a break to the server to issue a sysrequest. Try that for example with CTRL-A B H to get a small help for sysrequests from the kernel.
  • CTRL-A C
    Start a second screen.
  • CTRL-A A
    Toggle the display of the last used screen.
  • CTRL-A <NR>
    Toggle screen with number <NR>.