About

Friday, June 1, 2012

CentOS serial console access

I have my old Laptop plugged into my local [headless] server with a RS-232 serial cable for convenient access when things go wrong (booting new kernels and toying with network settings).


Client
On the Laptop I use Minicom for a client, but gtkterm is a good graphical alternative. Run minicom with -s for the first time to configure the serial port:

$ dmesg | grep tty
[    0.000000] console [tty0] enabled
[    1.390457] 00:09: ttyS0 at I/O 0x3f8 (irq = 4) is a NS16550A
$ apt-get install minicom
$ minicom -s

Serial device: /dev/ttyS0
Bps/Par/Bits: 9600 8N1
Hardware Flow Control: Yes
Software Flow Control: no


Server
Found that CentOS 6.3 has no access on the serial port by default.













[root@supermicro ~]# dmesg | grep tty
console [tty1] enabled
console [ttyS0] enabled
serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
00:06: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
00:07: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A

Above we find out what ports we have on the server. Can now edit the /etc/inittab file (below) to attach a getty process to the serial port, this will allow us to login over the serial cable.

id:3:initdefault:
1:23:respawn:/sbin/agetty -h -L ttyS0 9600 linux

Grub

Edit /boot/grub/grub.conf to output grub on the serial port :

default=0
timeout=5
serial --unit=1 --speed=9600
terminal serial console --timeout=10

title CentOS (XXXXXXXXXX.el6.x86_64)
root (hd0,0)

kernel /vmlinuz-XXXXXXXXXX.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root nomodeset rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM vga=795 console=tty1 console=ttyS0,9600


initrd /initramfs-2.6.32-279.2.1.el6.x86_64.img

Now after rebooting the CentOS server I can use the serial cable to select which kernel I want to use, watch it boot and then login - without a monitor or working network connection.