CentOS - Serial Console (Null modem)

What is Serial console

In general it is possible to say that serial console is one of possibility how to manage a access for maintenance/configuration/administration to a server.

In this cause we are going to use a standard SERIAL interfaces of the server called as well COM or RS-232 port. Most of the mother boards are directly providing mentioned interface (or are providing only pins where you can connect the RS-232/COM/Serial interface). As well it is possible to bay converter for USB interface that will provide the RS-232 interface used at COM/Serial communication.

In general it is possible to get 9-pin and 25-pin RS-232 interface. It is based on historical reasons. Today most systems are using the compact 9-pin interface.

Way to use Serial console

Just a short use cause:

In the cause that you have a server located in data center where you are paying for each U in rack you would most probably like to safe each space in rack. I can imagine that you are not going to spent the space for a monitor, keyboard, mouse, … .

According to this, one of the possibility is to use serial console where you can connect your notebook and manage the server. (Another possibility is to use HP- ILO / RILO ; IBM- IMM ; Dell- DRAC console; … but probably you will have server without this possibility.)

Connect

Client for serial console

I do prefer to use this clients (but you can use as well another)

UX/Linux - Minicom
MS Windows - Putty

Cable (Null modem)

For connecting to a serial console you will use a cable with RS-232 interfaces called as well Serial cable or Null modem cable.

How to prepare the serial cable.

Configure Serial console on server

Where:

“ /boot/grub/grub.conf ”
“ /etc/securetty ”
“ /etc/init/serial.conf ”

At beginning we will need to agree on some configuration parameters. This will make us the life easier as we will need to configure same parameters on more as one please. To configure this parameters in same way will provide us the possibility to use one configuration of client for our server.

Parameter I'll use Description
Interface /dev/ttyS0 && /dev/tty0 This is the interface name that we will use for our configuration. Usually /dev/ttyS[0..3]
Speed 19200 Common used are: 1200, 2400, 4800, 9600, 19200, 38400, 57600 and 115200 bit/s
Word 8 Use for transfer a (8) data bits
Parity No Is used for checking of data. Based on the parity bite it is possible to detect incorrect transfer of data.
Stop bit 1 Is sent after sending each character to resinc. with sender.

Check supported interfaces

On server run this command. It will provide to you the current configureation of available serial interfaces.

# setserial -g /dev/ttyS*

/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4            # This one is possible to use
/dev/ttyS1, UART: 16550A, Port: 0x02f8, IRQ: 3            # This one is possible to use
/dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4           # Based on BIOS the IRQ/Data register is configured, interface is not present
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3           # Based on BIOS the IRQ/Data register is configured, interface is not present

Standard configuration of serial ports:

UX/Linux ~ MS name Interrupt Data Register
/dev/ttyS0 ~ Com1 IRQ4 0x03f8 ~ 3F8 (hex)
/dev/ttyS1 ~ Com2 IRQ3 0x02f8 ~ 2F8 (hex)
/dev/ttyS2 ~ Com3 IRQ4 0x03e8 ~ 3E8 (hex)
/dev/ttyS4 ~ Com4 IRQ3 0x02e8 ~ 2E8 (hex)

http://www.webopedia.com/quick_ref/IRQnumbers.asp

Enable serial console at Grub

Edit main grub configuration file:

#vi /boot/grub/grub.conf

Add this lines before the line starting with _fckg_QUOT_hiddenmenu

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

As well add to kernel boot configuration additional parameters:

console=tty0 console=ttyS1,19200n8

grub.conf shall look like:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd1,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_darkstar-root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd1,0)/grub/splash.xpm.gz
serial --unit=0 --speed=19200 --word=8 --parity=no --stop=1
terminal --timeout=8 console serial
hiddenmenu
title CentOS (2.6.32-431.1.2.0.1.el6.x86_64)
        root (hd1,0)
        kernel /vmlinuz-2.6.32-431.1.2.0.1.el6.x86_64 ro root=/dev/mapper/vg_darkstar-root rd_NO_LUKS LANG=en_US.UTF-8 rd_MD_UUID=561c30c0:28b68af8:51e00b3b:33c18a15 rd_LVM_LV=vg_darkstar/swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg_darkstar/root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet console=tty0 console=ttyS0,19200n8
        initrd /initramfs-2.6.32-431.1.2.0.1.el6.x86_64.img
title CentOS (2.6.32-431.el6.x86_64)
        root (hd1,0)
        kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/vg_darkstar-root rd_NO_LUKS LANG=en_US.UTF-8 rd_MD_UUID=561c30c0:28b68af8:51e00b3b:33c18a15 rd_LVM_LV=vg_darkstar/swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg_darkstar/root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet console=tty0 console=ttyS0,19200n8
        initrd /initramfs-2.6.32-431.el6.x86_64.img

Securetty

Append the console name of your serial console in to config file ”/etc/securetty“. This configuration will be used at ”/etc/init/serial.conf“ for configuring ”/sbin/agetty“.

# cat /etc/securetty
console
vc/1
vc/2
vc/3
vc/4
vc/5
vc/6
vc/7
vc/8
vc/9
vc/10
vc/11
tty1
tty2
tty3
tty4
tty5
tty6
tty7
tty8
tty9
tty10
tty11
ttyS0

Restart server

After this all steps are done you shall restart/reboot your server and connect your PC/notebook to your serial console to test if the serial communication is working.

Tested on

CentOS 6.5

URL's

Navigation
Print/export
QR Code
QR Code wiki:os:centos:centos-serial-console-null-modem (generated for current page)