Sunday, April 13, 2008

Linux Box Terminal via Serial Cable Console

Here example how to make linux box access login / terminal via serial console cable. Without monitor / keyboard cable. Use PC / Notebook with hyper terminal, minicom or Zterm via serial cable. This example use linux box with fedora core 4, minimal installation.

Step by step to configure linux box via serial console

1. check system serial support

# dmesg | grep tty
ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A

# setserial -g /dev/ttyS[01]
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: 16550A, Port: 0x02f8, IRQ: 3


2. configure inittab to support serial console login, add (copy/paste)

# Run agetty on COM1/ttyS0 and COM2/ttyS1
s0:2345:respawn:/sbin/agetty -L -f /etc/issueserial 9600 ttyS0 vt100
s1:2345:respawn:/sbin/agetty -L -f /etc/issueserial 9600 ttyS1 vt100


Here Example /etc/inittab file

# vi /etc/inittab

id:3:initdefault:

# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6

# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now

# When our UPS tells us power has failed, assume we have a few minutes
# of power left. Schedule a shutdown for 2 minutes from now.
# This does, of course, assume you have powerd installed and your
# UPS connected and working correctly.
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"

# If power was restored before the shutdown kicked in, cancel it.
pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"

# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

# Run agetty on COM1/ttyS0 and COM2/ttyS1
s0:2345:respawn:/sbin/agetty -L -f /etc/issueserial 9600 ttyS0 vt100
s1:2345:respawn:/sbin/agetty -L -f /etc/issueserial 9600 ttyS1 vt100
#s1:2345:respawn:/sbin/agetty -L -i 38400 ttyS1 vt100

# Run xdm in runlevel 5
x:5:once:/etc/X11/prefdm -nodaemon


3. welcome banner, create file /etc/issueserial

# vi /etc/issueserial

Welcome
Connected on \l at \b bps
\U


4. activate the new init file, force the init to re-read the config file

# init q


5. permit to login via serial console as the root user, edit /etc/securetty and add ttys0/1

console
ttyS0
ttyS1
vc/1


6. Test



7. verify process

# ps -ef | grep agetty
root 25519 1 0 15:22 ttyS1 00:00:00 /sbin/agetty -L -f /etc/issueserial 9600 ttyS1 vt100

No comments: